6
6
// This file must be imported before any lazy-loading is being attempted.
7
7
__webpack_public_path__ = `${ window . config ?. assetUrlPrefix ?? '/assets' } /` ;
8
8
9
+ // Ignore external and some known internal errors that we are unable to currently fix.
10
+ function shouldIgnoreError ( err ) {
11
+ const assetBaseUrl = String ( new URL ( __webpack_public_path__ , window . location . origin ) ) ;
12
+
13
+ if ( ! ( err instanceof Error ) ) return false ;
14
+ // If the error stack trace does not include the base URL of our script assets, it likely came
15
+ // from a browser extension or inline script. Ignore these errors.
16
+ if ( ! err . stack ?. includes ( assetBaseUrl ) ) return true ;
17
+ // Ignore some known internal errors that we are unable to currently fix (eg via Monaco).
18
+ const ignorePatterns = [
19
+ '/assets/js/monaco.' , // https://codeberg.org/forgejo/forgejo/issues/3638 , https://github.com/go-gitea/gitea/issues/30861 , https://github.com/microsoft/monaco-editor/issues/4496
20
+ ] ;
21
+ for ( const pattern of ignorePatterns ) {
22
+ if ( err . stack ?. includes ( pattern ) ) return true ;
23
+ }
24
+ return false ;
25
+ }
26
+
9
27
const filteredErrors = new Set ( [
10
28
'getModifierState is not a function' , // https://github.com/microsoft/monaco-editor/issues/4325
11
29
] ) ;
@@ -47,7 +65,6 @@ export function showGlobalErrorMessage(msg) {
47
65
*/
48
66
function processWindowErrorEvent ( { error, reason, message, type, filename, lineno, colno} ) {
49
67
const err = error ?? reason ;
50
- const assetBaseUrl = String ( new URL ( __webpack_public_path__ , window . location . origin ) ) ;
51
68
const { runModeIsProd} = window . config ?? { } ;
52
69
53
70
// `error` and `reason` are not guaranteed to be errors. If the value is falsy, it is likely a
@@ -60,11 +77,8 @@ function processWindowErrorEvent({error, reason, message, type, filename, lineno
60
77
if ( runModeIsProd ) return ;
61
78
}
62
79
63
- // If the error stack trace does not include the base URL of our script assets, it likely came
64
- // from a browser extension or inline script. Do not show such errors in production.
65
- if ( err instanceof Error && ! err . stack ?. includes ( assetBaseUrl ) && runModeIsProd ) {
66
- return ;
67
- }
80
+ // In production do not display errors that should be ignored.
81
+ if ( runModeIsProd && shouldIgnoreError ( err ) ) return ;
68
82
69
83
let msg = err ?. message ?? message ;
70
84
if ( lineno ) msg += ` (${ filename } @ ${ lineno } :${ colno } )` ;
0 commit comments