-
-
Notifications
You must be signed in to change notification settings - Fork 936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve stacktrace when wrapping errors #935
Preserve stacktrace when wrapping errors #935
Conversation
t.true(error.stack.includes('at Object.request')); | ||
|
||
// The first `at get` points to where the error was wrapped, | ||
// the second `at get` points to the real cause. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now:
GotError: foobar
at get (/home/szm/Desktop/got/source/request-as-event-emitter.ts:250:15)
+ at Object.request (/home/szm/Desktop/got/test/error.ts:206:10)
+ at get (/home/szm/Desktop/got/source/request-as-event-emitter.ts:248:31)
at Immediate.<anonymous> (/home/szm/Desktop/got/source/request-as-event-emitter.ts:313:4)
Before:
GotError: foobar
at get (/home/szm/Desktop/got/source/request-as-event-emitter.ts:250:15)
-- the line above only points to where the error was captured --
-- missing what caused the error --
at Immediate.<anonymous> (/home/szm/Desktop/got/source/request-as-event-emitter.ts:313:4)
As you can see, the stacktrace begins with To fix this, we need to either remove |
Why do we even have it there? From what I faintly can remember, it had something to do with a race issue. Maybe we could fix it another way and remove the
I doubt it has big impact on performance relatively to networking. Did you check if the |
Yep, it's the same.
(() => {
let timings = [];
let start;
for (let i = 0; i < 100000; i++) {
start = performance.now();
(new Error()).stack;
timings.push(performance.now() - start);
}
return timings.reduce((a, b) => a + b) / timings.length;
})(); gives me
It was introduced here: #304 We can remove it because the errors are handled in a much different way than at the time. |
I'll fix this in a few hours, need sleep now |
d7e7bd3
to
a1b1c61
Compare
We need |
@szmarczak Is this supposed to solve the async stack trace problems? On 10.6.0 I get a stack trace that look like this:
I have no idea where this error occurs :) My request looks something like this:
|
@magnusottosson The title of the PR says "when wrapping errors", not "when handling async errors". You're confusing this PR with #1077 |
Ah sorry. My bad :) |
Fixes #795
Checklist
If it's a new feature, I have included documentation updates.