Bug 1530843 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

`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 `asyncProperty` links, and include `asyncCause` values in the reported stacks.
`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.

Back to Bug 1530843 Comment 0