From: Alexander Ebert Date: Sat, 14 May 2022 14:32:17 +0000 (+0200) Subject: Suppress error messages when aborting `fetch()` X-Git-Tag: 5.5.0_Beta_3~38 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5c92243cc2464bd31a666d5a3e81c34fe734ad20;p=GitHub%2FWoltLab%2FWCF.git Suppress error messages when aborting `fetch()` See https://www.woltlab.com/community/thread/295566-fetch-is-aborted-bei-suchergebnissen/ --- diff --git a/ts/WoltLabSuite/Core/Ajax/DboAction.ts b/ts/WoltLabSuite/Core/Ajax/DboAction.ts index 92b9f1266d..33cc993078 100644 --- a/ts/WoltLabSuite/Core/Ajax/DboAction.ts +++ b/ts/WoltLabSuite/Core/Ajax/DboAction.ts @@ -157,6 +157,13 @@ export class DboAction { if (error instanceof ApiError) { throw error; } else { + if (error instanceof DOMException && error.name === "AbortError") { + // `fetch()` will reject the promise with an `AbortError` when + // the request is either explicitly (through an `AbortController`) + // or implicitly (page navigation) aborted. + return; + } + if (!ignoreConnectionErrors) { // Re-package the error for use in our global "unhandledrejection" handler. throw new ConnectionError(error); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/DboAction.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/DboAction.js index 664692bc7c..adb1a29011 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/DboAction.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/DboAction.js @@ -112,6 +112,12 @@ define(["require", "exports", "tslib", "./Error", "./Status", "../Core"], functi throw error; } else { + if (error instanceof DOMException && error.name === "AbortError") { + // `fetch()` will reject the promise with an `AbortError` when + // the request is either explicitly (through an `AbortController`) + // or implicitly (page navigation) aborted. + return; + } if (!ignoreConnectionErrors) { // Re-package the error for use in our global "unhandledrejection" handler. throw new Error_1.ConnectionError(error);