NodeJS: Is it possible to show the stack trace of the calling asynchronous function?

Most of the APIs in the node libraries are asynchronous in design. When an exception is thrown in the callback, stacktrace only shows the call stack starting with process._tickCallback.

I wonder if there is a trick to show also the stack trace of the function, which trigerred _tickCallback.

+5
source share
2 answers

async_hooks 8 version of async_hooks appeared in node

trace uses this to trace the asynchronous stack

+1
source

You can take a look at the long stacks to see if it fits your needs. The module is called stackups. All you do is install it:

 npm install --save stackup 

and then require:

 require('stackup'); 

More info here: https://github.com/groundwater/node-stackup

0
source

Source: https://habr.com/ru/post/1258928/


All Articles