5
lotd
82d

Anybody else that low-key hates step debugging async code in nodejs ?

Miss the simplicity of synchronously execution flow… Like debugging php with xdebug ☺️

Comments
  • 3
    Async debugging is always more tricky but its usually worth it during to the better performance of the code :)
  • 0
    Just await it :p
    Yeah, i got no idea how to track it between events/threads too
  • 0
    Or, don't get excited and furious, write unit and runtime tests like a normal maniac writing multithreaded code.
  • 3
    Last time I had to deal with it, Node.js didn't give me the part of the call stack below an unawaited async call, including the unawaited call site itself. Most annoying debugging session of my life.
  • 0
    Also the async call stack is an unbounded heap allocated linked list that isn't tracked as a named user struct so infinite recursion becomes an out-of-memory error where the heap usage report doesn't contain anything unusual.
  • 0
    @melezorus34 got unit tests, in those everything passes, even ran in parallel.
    Tracked it down to be due to a race condition where timeout triggers and the last promise resolves before the queue flushes…

    new Promise(async (yay, nay) => {
    setTimeout(() => nay(“timeout”, 750));
    await calculations();
    await syncRemoteService();
    insertIntoDB().then(yay).catch(nay);
    });
Add Comment