Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Ajax: Protect against exceptions thrown synchronously by xhr.send
When xhr.send throws an exception synchronously, the onerror handler may have been called already which, unchecked, makes the exception bubble up outside of jQuery.ajax. We now catch the exception pre-emptively and only rethrow if we know it hasn't already been notified through the onerror handler. Fixes #14683
- Loading branch information
Showing
2 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -112,10 +112,15 @@ jQuery.ajaxTransport(function( options ) { | ||
// Create the abort callback | ||
callback = xhrCallbacks[ id ] = callback("abort"); | ||
|
||
// Do send the request | ||
// This may raise an exception which is actually | ||
// handled in jQuery.ajax (so no try/catch here) | ||
xhr.send( options.hasContent && options.data || null ); | ||
try { | ||
jaubourg
Author
Member
|
||
// Do send the request (this may raise an exception) | ||
xhr.send( options.hasContent && options.data || null ); | ||
} catch ( e ) { | ||
// #14683: Only rethrow if this hasn't been notified as an error yet | ||
if ( callback ) { | ||
throw e; | ||
} | ||
} | ||
}, | ||
|
||
abort: function() { | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@jaubourg Shouldn't there be a support comment about Chrome:
Support: Chrome 32+
?