-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Deferred: Respect source maps in jQuery.Deferred.exceptionHook #5192
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
Conversation
So far, `jQuery.Deferred.exceptionHook` used to log error message and stack separately. However, that breaks browser applying source maps against the stack trace - most browsers require logging an error instance. This change makes us do exactly that. One drawback of the change is that in IE 11 previously stack was printed directly and now just the error summary; to get to the actual stack trace, three clicks are required. This seems to be a low price to pay for having source maps work in all the other browsers, though. Safari with the new change requires one click to get to the stack trace which sounds manageable. Fixes jquerygh-3179 Ref https://crbug.com/622227
42f40e5 to
b418fc2
Compare
|
I know this doesn't solve ALL the issues outlined in #3179 (in particular, it doesn't address issues tackled by @dmethvin's https://github.com/dmethvin/jquery-deferred-reporter) but at least the source is mapped & formatted by the browser properly now, you can click to the source and the error is highlighted there. |
| error.stack, | ||
| "jQuery.Deferred exception", | ||
| error, | ||
| stack |
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.
I wonder about the name of this argument. The idea was to fill it in via https://github.com/dmethvin/jquery-deferred-reporter or something equivalent but that would hit the same issue with unmapped source maps for that additional stack. Should we assume that we should also pass a full error object here instead?
@dmethvin thoughts?
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.
One difficulty is the name of the hook is jQuery.Deferred.getStackHook so it explicitly talks about stack, not an error...
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.
We could introduce a new jQuery.Deferred.getErrorHook perhaps and deprecate the old hook?
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.
Good idea! I'll do this separately. This will mostly just be a rename as we'll be using it in the same way, just the recommendation will change.
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.
I submitted #5201 to track this.
timmywil
left a comment
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.
Thanks for doing this! Makes sense to just log the error object.
dmethvin
left a comment
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.
It's been forever since I looked at the way browsers handled stack traces in the console, especially for Promises. I think they've gotten a lot better, for example V8 enabled async stack traces in 2019. So this PR should improve things.
Summary
So far,
jQuery.Deferred.exceptionHookused to log error message and stack separately. However, that breaks browser applying source maps against the stack trace - most browsers require logging an error instance. This change makes us do exactly that.One drawback of the change is that in IE 11 previously stack was printed directly and now just the error summary; to get to the actual stack trace, three clicks are required. This seems to be a low price to pay for having source maps work in all the other browsers, though.
Safari with the new change requires one click to get to the stack trace which sounds manageable.
Fixes gh-3179
Ref https://crbug.com/622227
-12 bytesI'd like to keep it a 4.x item only, for two reasons:
console.warnpattern and changing it would break themI used a modified test case from gh-3179:
Screenshots comparing before & after below. One error coming from jQuery is available even in the "before" case as we still have
jQuery.readyExceptionthat re-throws errors from jQuery ready.Chrome
Before
After
Firefox
Before
After
Safari
Before
After
Initial view
After a single click on each exception
IE 11
Before
After
Initial view
After the 1st click
After the 2nd click
After the 3rd click
Checklist