Description
What is the problem this feature will solve?
Somewhere in my program I believe I have a Promise
that never resolves/rejects, and it's difficult to troubleshoot without modifying the code:
- I could add log statements everywhere
- I could wrap every existing promise in a
Promise.race([PromiseWithTimeout, OriginalPromise])
- I could get v21+ and use
--trace-promises
to see if it prints enough information for me to figure out which promise is stuck.
While I haven't tried 3., it sounds extremely useful. That said, in a situation where the program hangs without error, I think a similar feature may be a better tool for the job: The ability to dump the current stack/callback/promises of a running program. As far as I know, this feature doesn't exist in node, but it does in other runtimes (see below).
For the original context of this feature request, see my StackOverflow post titled, How do you find the stack trace of a JavaScript Promise that never resolves?
What is the feature you are proposing to solve the problem?
In my SO post I mention that "Java has ways to see all the stack traces of all the threads of a program." [by running kill -3 <java_process_id>
]. I'd like to request a similar feature in node.js.
What alternatives have you considered?
I've mentioned three alternatives in the list above.