Skip to content

Commit

Permalink
Deferred: Respect source maps in jQuery.Deferred.exceptionHook
Browse files Browse the repository at this point in the history
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 gh-3179
Closes gh-5192
Ref https://crbug.com/622227
  • Loading branch information
mgol committed Feb 1, 2023
1 parent 6d13644 commit 0b9c503
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/deferred/exceptionHook.js
Expand Up @@ -10,8 +10,8 @@ jQuery.Deferred.exceptionHook = function( error, stack ) {

if ( error && rerrorNames.test( error.name ) ) {
window.console.warn(
"jQuery.Deferred exception: " + error.message,
error.stack,
"jQuery.Deferred exception",
error,
stack
);
}
Expand Down
6 changes: 3 additions & 3 deletions test/unit/deferred.js
Expand Up @@ -575,9 +575,9 @@ QUnit.test( "jQuery.Deferred.exceptionHook", function( assert ) {
defer = jQuery.Deferred(),
oldWarn = window.console.warn;

window.console.warn = function() {
var msg = Array.prototype.join.call( arguments, " " );
assert.ok( /barf/.test( msg ), "Message: " + msg );
window.console.warn = function( _intro, error ) {
assert.ok( /barf/.test( error.message + "\n" + error.stack ),
"Error mentions the method: " + error.message + "\n" + error.stack );
};

jQuery.when(
Expand Down

0 comments on commit 0b9c503

Please sign in to comment.