Glossary / Promise states
Promise states
A Promise has one of three mutually exclusive states: pending, fulfilled, or rejected. Fulfilled and rejected are settled states; settlement is irreversible. “Resolved” is not a synonym for fulfilled: a Promise is resolved once it is locked to follow another value/thenable, even if that adopted Promise is still pending.
State transitions
const pending = new Promise((resolve) => setTimeout(() => resolve(5), 100));
A pending Promise may fulfill or reject once. Calling resolve with a plain value fulfills it; calling resolve with a Promise/thenable adopts that outcome. Calling reject rejects it. Repeated resolve/reject calls after resolution are ignored, and resolving a Promise with itself rejects with TypeError. A Promise constructor’s executor is called synchronously, and an exception escaping it rejects the Promise.
There is no supported API to synchronously inspect a Promise’s current state. Consumers register reactions and receive the outcome asynchronously. This avoids timing-dependent state polling. A Promise can represent completion, but does not guarantee the underlying work has stopped if the Promise is rejected or ignored.
Interview questions
- What are the three Promise states? Pending, fulfilled, rejected.
- What does settled mean? Fulfilled or rejected.
- Can a resolved Promise still be pending? Yes, if it has adopted another pending Promise/thenable.
- Can a Promise change after settlement? No.
- How inspect state? There is no standard synchronous state-inspection API; attach handlers/await it.