Promise Resolve Called Twice: What It Means and How to Fix It
Error reference
Promise Resolve Called Twice
Language
Severity
LowWhen it happens
Calling resolve() or reject() more than once inside a Promise constructor is silently ignored.
Potential fixes
Promises model a single future value. For multiple values, use an EventEmitter, RxJS Observable, or an async generator. Ensure that each code path inside the Promise executor calls either resolve or reject exactly once, then returns.
Related errors
Deep dive
Calling resolve() or reject() more than once inside a Promise constructor is silently ignored. A Promise can only be settled once. This is not an error per se, but a common source of subtle bugs where developers expect multiple values or callbacks from a single promise.
Why it happens
- •A callback-based API calls its callback more than once, and each call triggers resolve.
- •Both a success path and an error path call resolve instead of one calling reject.
- •An event listener inside a Promise constructor fires multiple times.
Potential fixes
Promises model a single future value. For multiple values, use an EventEmitter, RxJS Observable, or an async generator. Ensure that each code path inside the Promise executor calls either resolve or reject exactly once, then returns.
Examples
Code that triggers the error
const p = new Promise((resolve, reject) => {
resolve("first");
resolve("second"); // silently ignored
reject(new Error("oops")); // also silently ignored
});
const val = await p;
console.log(val); // "first"Error output
first // No error is thrown. The second resolve and the reject are silently ignored.
Fixed code
// Promise state is immutable once settled.
// If you need multiple values, use an event emitter or async generator.
async function* stream() {
yield "first";
yield "second";
}
for await (const val of stream()) {
console.log(val);
}Practice in English
How would you explain a Promise Resolve Called Twice to a fellow dev? Choose the right phrase:
"I hit an error...
Ready to practice your English at work?
Lingua-e has interactive exercises built around real developer conversations: standups, code reviews, retrospectives, and more. Practice until it comes naturally.
Try Lingua-e for free