freecoding.school100% FREE · NO SIGNUP
Await StationISSUE #2 of 26

callback hell · the nested problem

PromissaVSRace Condition Rex
Promissa says"Callback hell" is the deeply nested pyramid from sequencing many callbacks — promises fix it.

When step B needs A's result and C needs B's, nested callbacks form a rightward "pyramid of doom" that's hard to read and error-handle. Each level needs its own error check. Promises flatten this into a linear .then() chain, and async/await makes it read like synchronous code — which is why both exist.

Power-ups you unlock

Race Condition Rex attacks — common mistakes

Boss battleRecognize a 3-level nested-callback pyramid, then picture it as a flat .then() chain.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>stepA(a => {
  stepB(a, b => {
    stepC(b, c => {   // ← the pyramid
      done(c);
    });
  });
});
// promises flatten this into A.then(B).then(C)</pre></body></html>
▶ Open the interactive comic issue
‹ Callbacks · The Original AsyncPromises · Pending · Fulfilled · Rejected ›