fix: make fetch error not abort.

This commit is contained in:
Rintim 2024-04-25 23:20:19 +08:00
parent 2797d1eed4
commit 38106caecf
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
3 changed files with 4 additions and 0 deletions

View File

@ -81,6 +81,7 @@ export class ChromePromiseErrorHandler {
event.promise.catch((error) => {
// 如果`error`是个错误,则继续处理
if (error instanceof Error) {
if (/Failed to fetch/.test(error.message) || /Failed to load because no supported source was found/.test(error.message)) return;
// 如果已经处理过该错误,则不再处理
if (this.#errorList.includes(error)) return;
this.#errorList.push(error);

View File

@ -18,6 +18,8 @@ export class FirefoxPromiseErrorHandler {
onHandle(event) {
event.promise.catch((error) => {
if (typeof error === "object" && error instanceof Error) {
if (/Failed to fetch/.test(error.message) || /The media resource indicated by the src attribute or assigned media provider object was not suitable/.test(error.message)) return;
// Firefox在大环境下默认情况必须要那么多ts-ignore
// @ts-ignore
window.onerror(

View File

@ -20,6 +20,7 @@ export class UnknownPromiseErrorHandler {
onHandle(event) {
event.promise.catch((error) => {
if (typeof error === "object" && error instanceof Error) {
if (/Failed to fetch/.test(error.message)) return;
// 很遗憾,因浏览器问题,你只能看到这一段
throw error;
}