Given the recent PR ( #5020 ) I wanted to see if promises could enable core dump based debugging.
It looks like currently when an unhandledRejection
occurs the stack is gone. This is very similar to how the stack is gone when an uncaughtException
occurs.
We've added --abort-on-uncaught-exception
flag to allow us to abort the process with the correct stack in C++. We need to implement --abort-on-unhandled-rejection
flag as well.
See foo.js example
process.on('unhandledRejection', function onError(err) {
throw err;
});
function foo() {
new Promise(function reject(re, rj) { rj(new Error('sad')) });
}
foo();
raynos at raynos-SVS15127PXB ~
$ node foo.js
/home/raynos/foo.js:2
throw err;
^
Error: sad
at reject (/home/raynos/foo.js:6:46)
at foo (/home/raynos/foo.js:6:5)
at Object.<anonymous> (/home/raynos/foo.js:8:1)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
Note the error has the correct stacktrace including foo
and reject
raynos at raynos-SVS15127PXB ~
$ node --abort-on-uncaught-exception foo.js
Uncaught Error: sad
FROM
process.onError (/home/raynos/foo.js:2:6)
emitTwo (events.js:87:13)
process.emit (events.js:172:7)
emitPendingUnhandledRejections (node.js:500:24)
runMicrotasksCallback (node.js:329:11)
doNTCallback0 (node.js:419:9)
process._tickCallback (node.js:348:13)
Function.Module.runMain (module.js:469:11)
startup (node.js:136:18)
node.js:963:3
Illegal instruction
Note that the actual stack of the program when in the unhandledRejection
listener is wrong. This means we cannot just process.abort()
in there since that's absolutely useless, I want to stack that mattered.
I considered this a MUSTFIX before we land promises into core, if we cannot debug promises then there is not point in using it. The only good feature nodejs has is extreme debuggability.
cc: @chrisdickinson @misterdjules
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4