asap icon indicating copy to clipboard operation
asap copied to clipboard

Usability in development mode with thrown errors

Open kriskowal opened this issue 9 years ago • 5 comments

Evidently, at least in recent Chrome, errors that are captured and released asynchronously lose their stack traces.

Options to mitigate this would include at least:

  1. rework how we deal with errors, allowing errors to pass through synchronously after we request another flush, at least in development mode if not in production as well, at the expense of the performance and priority of flushing a queue with uncaught exceptions.
  2. find a way to capture the stack trace on the error before deferring. preliminary attempts failed.

cc @rkatic

kriskowal avatar Apr 12 '15 15:04 kriskowal

I noticed this recently as well. It seems like a bug in the chrome dev tools: if I put a breakpoint where the error is being re-thrown and inspect err.stack manually I get the correct value.

ForbesLindesay avatar Apr 12 '15 16:04 ForbesLindesay

Need to produce an isolated case and send it to Chromium https://code.google.com/p/chromium/issues/list

But will also have to work around the problem here, for now.

kriskowal avatar Apr 13 '15 00:04 kriskowal

I'm not sure if hacking around the problem here will be of much use to most promise libraries. I suspect it will only fix the problem in certain isolated cases.

ForbesLindesay avatar Apr 13 '15 13:04 ForbesLindesay

Attempts to isolate have so far been in vain.

I created a bundle from the following and it did not exhibit the missing stack trace problem in Chrome dev tools.


var asap = require('./asap');

asap(function () {
    throw new Error('Fake');
});

I also tried this stand-alone, gradually adding complications without being able to reproduce the problem:

var pendingErrors = [];

function requestThrow() {
    setTimeout(rethrow);
}

function rethrow() {
    throw pendingErrors.shift();
}

function stackFrame() {
    try {
        indirection();
    } catch (error) {
        pendingErrors.push(error);
        requestThrow();
    } finally {
    }
}

function indirection() {
    throw new Error("Example");
}

setTimeout(function () {
    stackFrame();
}, 100);

So there appears to be an exogenous factor.

kriskowal avatar Apr 25 '15 23:04 kriskowal

We could always add an asap.forceSyncThrow. Finding a workaround for this issue could be difficult and unreliable. I'm willing to investigate more on this, but this month I will still probably not have much free time.

rkatic avatar Jul 02 '15 18:07 rkatic