Console actor drops asynchronous stacks from nsIConsoleService
Categories
(DevTools :: Console, defect, P2)
Tracking
(firefox73 fixed)
| Tracking | Status | |
|---|---|---|
| firefox73 | --- | fixed |
People
(Reporter: jimb, Assigned: nchevobbe)
References
(Blocks 1 open bug)
Details
Attachments
(2 files, 1 obsolete file)
WebConsoleActor.prototype.preparePageErrorForRemote doesn't check stack frames' asyncParent property when transcribing the nsIScriptError's stack into an array for inclusion in the pageError packet sent to the client. The result is that stacks provided via the console service lack asynchronous callers when displayed in the console.
For example, evaluate the following in the console:
function a() {
setTimeout(() => { throw new Error("bleah"); }, 2000);
}
function b() {
a();
}
b();
The evaluation returns immediately; the result is undefined. Two seconds later, the setTimeout callback runs, and throws an exception. The exception is logged in the console with a stack that includes only the anonymous function in a, not a itself or its caller b.
The console learns about this uncaught exception via a listener it registered with nsIConsoleService. The stack attached to the error report includes the anonymous inner function, a, and b. However, since a is not the caller of the anonymous inner function, a is listed as its 'asynchronous caller': it appears as the anonymous function's stack frame's asyncParent property, while its parent property is null.
The preparePageErrorForRemote method is not aware of the asyncParent property, nor of the asyncCause property on the asynchronous caller frame, which explains by what mechanism the callee was dispatched (in the case above, it would be "setTimout handler"). It should follow asyncParent links, and include asyncCause values in the reported stacks.
| Reporter | ||
Comment 1•6 years ago
|
||
| Reporter | ||
Comment 2•6 years ago
|
||
| Reporter | ||
Comment 3•6 years ago
|
||
The above is almost certainly not a complete fix; I assume there are other parts of the code that also walk stacks. But with that patch applied, I can get stack traces like this:
(In case that inline image doesn't work, it's just a link to the attachment.)
| Assignee | ||
Comment 4•6 years ago
|
||
Thanks a lot Jim for looking into this.
Can I offer to write the test for this fix?
| Reporter | ||
Comment 5•6 years ago
|
||
Actually - would you be willing to take the bug altogether? :D
There may be other places in the code that need similar treatment.
| Assignee | ||
Comment 6•6 years ago
|
||
Sure :)
I'll look for other places
| Reporter | ||
Updated•6 years ago
|
| Assignee | ||
Comment 8•6 years ago
|
||
Jim, would you happen the test case where you managed to get the async trace to work (Comment 2)?
I'm trying with the snippet from Comment 0 but I only get the last SavedFrame, and both asyncCause and asyncParent are null.
Does this need other patches?
| Reporter | ||
Comment 9•6 years ago
|
||
Huh, there should never be a truncated stack, given the code in comment 0. I had no further patches applied.
Comment 2 refers to Honza's test cases: https://outstanding-cowl.glitch.me/
referenced from the document here:
https://docs.google.com/document/d/1fEc8l0eXCflHH1qgRruoWU5i9WtpalKHwVgBxtHae7Y/edit#heading=h.gntwt77eq3hu
| Assignee | ||
Comment 10•5 years ago
|
||
Comment 11•5 years ago
|
||
Comment 12•5 years ago
|
||
| bugherder | ||
Updated•3 years ago
|
Description
•