Skip to content
DevMeme
3132 of 7435
Nested Promise Chain Demonstrates Callback Hell on the Way to the Doctor
CodeQuality Post #3451, on Jul 23, 2021 in TG

Nested Promise Chain Demonstrates Callback Hell on the Way to the Doctor

Description

Dark-themed editor screenshot shows heavily indented JavaScript code. Exact text: 1 if (received(news)) { 2 move(10).then(() => { 3 go.to(door).then(() => { 4 move(10).then(() => { 5 go.to(reception).then(() => { 6 talk.to(receptionist).then(() => { 7 move(10).then(() => { 8 talk.to(doctor).then(() => { 9 move(10).then(() => { 10 //I am legally not allowed to finish this joke 11 }).catch(); 12 }).catch(); 13 }).catch(); 14 }).catch(); 15 }).catch(); 16 }).catch(); 17 }).catch(); 18 }).catch(); 19 } Keywords like "if" and method names are colored, and the comment on line 10 appears in green. The extreme nesting of `.then()` calls forms an indentation pyramid, humorously illustrating “callback hell” and poor maintainability in asynchronous JavaScript. The final comment, "//I am legally not allowed to finish this joke", lampoons how long promise chains can become before any real logic executes, making it relatable developer humor about code quality and readability

Comments

27
Anonymous ★ Top Pick Our new HIPAA strategy: bury the PHI eleven .then() deep - by the time anyone reaches talk.to(doctor), both the token and the developer have expired
  1. Anonymous ★ Top Pick

    Our new HIPAA strategy: bury the PHI eleven .then() deep - by the time anyone reaches talk.to(doctor), both the token and the developer have expired

  2. Anonymous

    This code walks into a doctor's office, but after 10 levels of callbacks, even the JavaScript engine needed therapy. The real diagnosis? Acute Promise deficiency with chronic async/await avoidance disorder - a condition that affects legacy codebases where developers are still billing by the indentation level

  3. Anonymous

    This is what happens when you explain async/await to a junior developer but they're still mentally stuck in 2015. Seven levels deep and the comment 'I am legally not allowed to finish this joke' is the most honest documentation I've seen all week - probably because their lawyer saw the code review and filed a restraining order against the codebase. The real punchline? Someone on the team will inevitably suggest 'just add another .catch() to handle that edge case' during the next sprint planning

  4. Anonymous

    Nine .catch()s and no returns - the Promise Pyramid of Doom; one async function with try/catch would halve your indentation and your incident count

  5. Anonymous

    Enterprise JS: hospital triage in nested .then(), .catch() at every indent so Legal sleeps - Promises didn’t fix callback hell; they gave it a fluent API. Please, async/await

  6. Anonymous

    Architect's dream of bulletproof resilience: every exception caught by another exception handler, ensuring the stack trace - and deadlines - never resolve

  7. @iamnikas 4y

    Ваши действия: 1. Отрезать яйца 🥚 2. Оторвать руки

    1. @sylfn 4y

      (This is English-only chat) Your action: (1) cut balls, (2) cut arms

      1. @iamnikas 4y

        Thnk u

      2. @phpzapecanus 4y

        Mb rip off

  8. @Alex_42ml 4y

    How many people know the Loss meme here to understand this joke?

    1. @beton_kruglosu_totchno 4y

      I recalled it just because of doctor and reception but then I do not understand wtf is "move(10)" and legal problems.

      1. @fortrest 4y

        Same

  9. @Baksy93 4y

    Only those who experienced it a dozen times or so

  10. @azizhakberdiev 4y

    why do we need await

    1. @metal_Dash 4y

      Or just return promise in the chain

  11. Deleted Account 4y

    That's what async/await syntax made for

  12. @saidov 4y

    Callback hell

  13. @saidov 4y

    My favorite hell

    1. @kitbot256 4y

      The one you can avoid simply by promising stuff?

      1. @saidov 4y

        I don’t use promises much often, I use observables

  14. @thisisluxion 4y

    this is terrifying

  15. @Amir_0234 4y

    Wait, is this ...

  16. @phpzapecanus 4y

    Or tear off

  17. @phpzapecanus 4y

    Arms

  18. Deleted Account 4y

    Explain please

  19. @zuluuus 4y

    Василий.

Use J and K for navigation