-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π Don't report request cancellation errors
- Loading branch information
Showing
1 changed file
with
39 additions
and
2 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 |
---|---|---|
|
@@ -332,6 +332,30 @@ Scene.setMethod(function fetch(href, options, callback) { | |
return this.general_renderer.fetch(href, options, callback); | ||
}); | ||
|
||
/** | ||
* Is the given error a request cancellation? | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 2.4.0 | ||
* @version 2.4.0 | ||
* | ||
* @param {Error} err | ||
* | ||
* @return {boolean} | ||
*/ | ||
function isRequestCancellationError(err) { | ||
|
||
if (!err) { | ||
return false; | ||
} | ||
|
||
if (err.status == 0 && err.number == 0) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Browse to a link using AJAX. | ||
* The response will be an item this client needs to render. | ||
|
@@ -491,6 +515,7 @@ Scene.setMethod(function openUrl(href, options, callback) { | |
} | ||
|
||
let error = new Error('Request has been cancelled'); | ||
error.status = error.number = 0; | ||
pledge.reject(error); | ||
|
||
return false; | ||
|
@@ -3006,7 +3031,7 @@ Scene.setMethod(function detectDoubleClick(request, min_duration) { | |
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 2.0.0 | ||
* @version 2.3.3 | ||
* @version 2.4.0 | ||
* | ||
* @param {HTMLElement} element | ||
* @param {HTMLEvent} e | ||
|
@@ -3120,6 +3145,12 @@ Scene.setMethod(function onLinkClick(element, e) { | |
} | ||
|
||
if (err) { | ||
|
||
// Ignore cancellations | ||
if (isRequestCancellationError(err)) { | ||
return; | ||
} | ||
|
||
if (typeof that.errorHandler == 'function') { | ||
that.errorHandler(err, {type: 'openUrl', options: options, url: href}); | ||
} else { | ||
|
@@ -3170,7 +3201,7 @@ Scene.setMethod(function markElementBusy(element, busy) { | |
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 2.0.0 | ||
* @version 2.3.18 | ||
* @version 2.4.0 | ||
* | ||
* @param {HTMLElement} form | ||
* @param {HTMLEvent} e | ||
|
@@ -3248,6 +3279,12 @@ Scene.setMethod(function onFormSubmit(form, e, options) { | |
} | ||
|
||
if (err) { | ||
|
||
// Ignore cancellations | ||
if (isRequestCancellationError(err)) { | ||
return; | ||
} | ||
|
||
return console.error(err); | ||
} | ||
|
||
|