Example:
f()
async function f() {
await g()
}
async function g() {
await 42 // stack trace includes f without this line
throw Error()
}
Prints:
Possibly unhandled promise rejection: Error
at g (tmp/async.js:9:11)
f's stack frame is "lost", making debugging harder than it should be.
It should be possible to capture the stack in or around JS_EnqueueJob and stitch it back together in JS_ExecuteJob.
That obviously comes at some performance cost, so there should be a knob to control the length of the async stack trace, with zero meaning "off".
Up for the debate: the default setting of the knob.
The captured stack should be a rolling buffer where older entries drop off. Increase the reference count of JS functions when they're mixed into the captured stack, decrease them again when they drop off.
Example:
Prints:
f's stack frame is "lost", making debugging harder than it should be.
It should be possible to capture the stack in or around JS_EnqueueJob and stitch it back together in JS_ExecuteJob.
That obviously comes at some performance cost, so there should be a knob to control the length of the async stack trace, with zero meaning "off".
Up for the debate: the default setting of the knob.
The captured stack should be a rolling buffer where older entries drop off. Increase the reference count of JS functions when they're mixed into the captured stack, decrease them again when they drop off.