fix: don't report failed network requests as JavaScript errors (#38732)

On the issue ref popup, when the user clicks the link while fetch is
loading, the page will briefly render a network error message before
loading the next page. Suppress unnecessary network errors.
This commit is contained in:
silverwind
2026-08-03 06:11:22 +00:00
committed by GitHub
parent 6487d14855
commit 89dd456af8
3 changed files with 15 additions and 0 deletions
+1
View File
@@ -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",
+9
View File
@@ -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
+5
View File
@@ -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;