diff --git a/package.json b/package.json index 1e430f26fa..12e6418bf2 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "easymde": "2.21.0", "esbuild": "0.28.1", "idiomorph": "0.7.4", + "is-network-error": "1.3.2", "jquery": "4.0.0", "js-yaml": "5.2.2", "katex": "0.18.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1a75796119..db51d3e6b4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -137,6 +137,9 @@ importers: idiomorph: specifier: 0.7.4 version: 0.7.4 + is-network-error: + specifier: 1.3.2 + version: 1.3.2 jquery: specifier: 4.0.0 version: 4.0.0 @@ -2923,6 +2926,10 @@ packages: resolution: {integrity: sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==} engines: {node: '>= 0.4'} + is-network-error@1.3.2: + resolution: {integrity: sha512-PhBY86zaxNZUuWP6h13Vu5oFe0XY6/UlKzQnYFELzGVHygP3MxmvTfYSG7GN3aIab/iWudSMgjSnG9Dq+nHrgA==} + engines: {node: '>=16'} + is-number-object@1.1.1: resolution: {integrity: sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==} engines: {node: '>= 0.4'} @@ -7391,6 +7398,8 @@ snapshots: is-negative-zero@2.0.3: optional: true + is-network-error@1.3.2: {} + is-number-object@1.1.1: dependencies: call-bound: 1.0.4 diff --git a/web_src/js/modules/errors.ts b/web_src/js/modules/errors.ts index 0163fd8b52..7bf22db962 100644 --- a/web_src/js/modules/errors.ts +++ b/web_src/js/modules/errors.ts @@ -1,5 +1,6 @@ // keep this file lightweight, it's imported into IIFE chunk in bootstrap import {html} from '../utils/html.ts'; +import isNetworkError from 'is-network-error'; import type {Intent} from '../types.ts'; /** Extract a message string from an unknown caught value. */ @@ -66,6 +67,10 @@ export function processWindowErrorEvent({error, reason, message, type, filename, if (window.config.runModeIsProd) return; } + // Don't show network errors, happens on ref-issue when clicking on the + // issue link while the fetch request is still running. + if (isNetworkError(err)) return; + // Filter out errors from browser extensions or other non-Gitea scripts. if (!isGiteaError(filename ?? '', err?.stack ?? '')) return;