Menu

Does Promise.all() Cancel Other Promises When One Rejects?
📰

Does Promise.all() Cancel Other Promises When One Rejects?

DEV Community: backend·Shubhra Pokhariya·6 days ago
#vQ9R6KaL
#devtobackend#devto#dev#promise#rejected
Reading 0:00
15s threshold

When Promise.all() rejects, the promise it returns settles with the first rejection reason, and that is all that changes. Nothing is cancelled. The other input promises keep going, the operations behind them keep running, and any side effect they perform still happens, after your code has already moved on to the error path.

The table comes from a three-operation reproduction on Node.js 22.23.4. Operation A fails early, B succeeds later, and C writes to a store later still. Timings are approximate. The order of events is the result.

What you might ask What the run showed

Did the aggregate promise reject? Yes, at about 50 ms, with the same error object A rejected with

Did B, an input promise, still settle? Yes, it fulfilled at about 150 ms

Did C, the underlying operation, still run? Yes, it wrote to the store at about 250 ms, after the aggregate had rejected

Can B's value be read through the aggregate? No. It is only available from the promise b itself

Did anything cancel B or C? No.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.