Asyncintermediate
Promise Chaining Pitfalls
Common mistakes when chaining .then() calls, including forgetting to return, nested chains, and swallowed errors.
Promise chaining looks straightforward, but a handful of mistakes routinely trip up developers, which is why interviewers use small snippets built around exactly these mistakes.
A missing return in a promise chain is like handing off a relay baton to the wrong routine — the runner keeps going with an empty hand, and nobody notices the real baton was dropped until someone reaches for it.
Key Concepts
1
The most common mistake is forgetting to return a value or promise from inside a .then() callback — without it, the callback implicitly returns undefined, and the next .then() receives that instead of the intended value, often silent until a downstream error occurs.
2
Another trap is nesting .then() calls instead of chaining them, recreating the pyramid-of-doom structure promises were meant to eliminate.
3
Error handling has its own subtlety: a single terminal .catch() catches rejections from any earlier step, but only if every step propagates its promise; if a .then() callback catches an error internally without re-throwing, the chain continues as if nothing went wrong, silently masking the failure.