- From: Mattias Buelens <notifications@github.com>
- Date: Sat, 23 Feb 2019 15:12:02 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/issues/985/466709728@github.com>
> When rethrowAssertionErrorRejection rethrows the exception, it loses the original stack. I investigated this a bit further. It turns out `rethrowAssertionErrorRejection` **does not** lose the stack trace! The problem lies in how `jsdom` propagates errors, and how the `VirtualConsole` logs errors by default. When `jsdom` turns an uncaught error into a `jsdomError` event, it places the original error in `e.detail` ([source](https://github.com/jsdom/jsdom/blob/13.0.0/lib/jsdom/living/helpers/runtime-script-errors.js#L67)). When a `VirtualConsole` receives such event, it calls `console.error(e.stack, e.detail)` ([source](https://github.com/jsdom/jsdom/blob/13.0.0/lib/jsdom/virtual-console.js#L29)). This logs the stack trace of the `jsdomError`, and the own properties of the original error: ``` Error: Uncaught [AssertionError: false == true] at reportException (C:\Users\Mattias\Documents\GitHub\whatwg-streams\reference-implementation\node_modules\jsdom\lib\jsdom\living\helpers\runtime-script-errors.js:66:24) at Timeout.callback [as _onTimeout] (C:\Users\Mattias\Documents\GitHub\whatwg-streams\reference-implementation\node_modules\jsdom\lib\jsdom\browser\Window.js:663:7) at ontimeout (timers.js:436:11) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10) AssertionError { name: 'AssertionError', actual: false, expected: true, operator: '==', message: 'false == true', generatedMessage: true } ``` Instead, we could have it log the stack trace of the original error instead with `console.error(e.detail.stack)`: ``` AssertionError: false == true at ReadableStreamDefaultControllerClose (eval at setup (C:\Users\Mattias\Documents\GitHub\whatwg-streams\reference-implementation\run-web-platform-tests.js:41:14), <anonymous>:1535:3) at ReadableStreamDefaultReaderRead.then.result (eval at setup (C:\Users\Mattias\Documents\GitHub\whatwg-streams\reference-implementation\run-web-platform-tests.js:41:14), <anonymous>:888:11) at process._tickCallback (internal/process/next_tick.js:68:7) ``` We could change this in `wpt-runner` by passing a custom `VirtualConsole` in `runTest` ([source](https://github.com/domenic/wpt-runner/blob/v2.7.0/lib/wpt-runner.js#L117)): ```js function runTest(url, setup, reporter) { return new Promise(resolve => { const virtualConsole = new VirtualConsole() .sendTo(console, { omitJSDOMErrors: true }) .on("jsdomError", e => console.error(e.detail.stack)); JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously", virtualConsole }).then(dom => { ``` Thoughts? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/issues/985#issuecomment-466709728
Received on Saturday, 23 February 2019 23:12:23 UTC