This is a micro post with a tip that I'll need to remember again in the months to come. Node.js can emit warnings on the terminal saying that a rejected promise wasn't caught, or calling an asynchronous function without callback is deprecated.

But where exactly is the original call that causes that warning?

Node warnings

Passing the command line argument --trace-warnings gives me a full stacktrace to the originating call that triggered the node warning:

Node warnings after

Note that even though I'm using mocha (via npx) the noe argument is still correctly passed on to node to give me the stacktrace.

You can even go a little further an include a module like clarify to strip the node internals from the stacktrace which makes it a little easier to read.

Want more?

Posts, web development learnings & insights, exclusive workshop and training discounts and more, direct to your inbox.

I won't send you any spam, and you can unsubscribe at any time. Powered by ConvertKit