Hacker News new | ask | show | jobs
by zebnyc 1546 days ago
Unrelated but does anyone have tips on debugging async code in Nodejs. My work has a gigantic Nodejs monorepo and frankly I am struggling so pointers would be appreciated. There is dependency injection & layers of async / await abstraction.

Not fun, when I model my code / unit test against a working sample and some method 25+ layers down does not work as expected as it does not have expected input when the stack frame does not even give me the caller. Is there a better way than peppering the codebase with logging statements?

1 comments

You can use the debugger from Chrome dev tools to debug Node.js. Just run node with the `—-inspect-brk` flag, open `about://inspect` in Chrome, and select your app under remote targets. This has saved me tons of debugging time. See also: https://nodejs.org/en/docs/guides/debugging-getting-started/