When is a promise considered "fulfilled"?
Short answer
A promise is considered "fulfilled"
when the asynchronous operation has completed successfully
and the resolve() function has been called -
that is, the promise now has a result (value).
Formally, in ECMAScript
A Promise object has three states:
| State | What it means | Can it change |
|---|---|---|
pending | "waiting" - the result is not yet known | Yes |
fulfilled | "completed successfully" - resolve() was called | No |
rejected | "completed with an error" - reject() was called | No |
After moving to fulfilled or rejected -
the state becomes final (immutable).
Example: a promise becomes "fulfilled"
const promise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('Data received');
}, 1000);
});
promise.then((result) => {
console.log(result);
});After 1 second, resolve('Data received') is called
-> the promise moves from pending -> to fulfilled,
and .then() runs.
When it is not considered fulfilled
1. As long as resolve() or reject() has not been called
new Promise(() => {
// we call nothing
});
// state: pending (forever)2. If the promise resolves with another promise (chaining)
const p = new Promise((resolve) => {
resolve(fetch('/data')); // resolve returns another Promise
});Then p will not settle until the nested Promise settles.
(the "promise unwrapping" mechanism).
Example with reject (an error)
const promise = new Promise((resolve, reject) => {
reject('Network error');
});
promise
.then(() => console.log('Success'))
.catch((err) => console.error(err));The promise is settled, but in the rejected state,
so .catch() runs.
When .then() / .catch() run
.then()fires only if the promise becomes fulfilled.catch()fires if it becomes rejected.finally()fires in any case, once the promise settles
Timing example
const p = new Promise((resolve) => {
console.log('1 pending');
setTimeout(() => resolve('2 fulfilled'), 2000);
});
p.then(console.log);
console.log('3 continuing execution');Sequence:
1 pending
3 continuing execution
2 fulfilledThe promise is "fulfilled" only after 2 seconds -
at the moment resolve() is called.
Summary: what "Promise fulfilled" means
| State | What happened | Methods that fire |
|---|---|---|
pending | operation in progress | none |
fulfilled | resolve() was called | .then(), .finally() |
rejected | reject() was called, or an error occurred | .catch(), .finally() |
A simple analogy
A promise is like a delivery
- While the order hasn't arrived ->
pending- The courier arrived with the package ->
fulfilled- The courier called: "address not found" ->
rejected
Conclusion
A Promise is considered "fulfilled"
when it moves from the pending state -> to one of the final ones:
fulfilled- successfully (resolve(value))rejected- with an error (reject(reason))
After that:
- the state no longer changes,
- and the result can be obtained via
.then(),.catch(), orawait.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.