Clean up and improve non-gitea js error filter#37148
Clean up and improve non-gitea js error filter#37148silverwind merged 5 commits intogo-gitea:mainfrom
Conversation
Explicitly detect and filter errors originating from browser extensions by checking for extension URL schemes (chrome-extension://, moz-extension://, safari-extension://, safari-web-extension://) in the error's filename and stack trace. This prevents unrelated extension errors from being shown to users. Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
bbd8284 to
1b319e3
Compare
Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
|
There is a similar condition below this one with the same purpose. I'll check if it makes sense to retain both conditions (defense in depth). Edit: Updated. |
Unify browser extension and asset URL checks into a single isGiteaError function. Filter non-Gitea errors in all modes, not just production. Add tests and fix vitest assetUrlPrefix to use realistic value. Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
|
@bircni if you could test this for your Safari error it would be great. If you can post the full stack trace from the browser console, it would be even greater. |
There was a problem hiding this comment.
Pull request overview
This PR refactors the frontend global error handler’s “non-Gitea JS error” filtering to reduce user-facing noise from browser extensions/external scripts, and updates tests/mocks accordingly.
Changes:
- Introduces an
isGiteaError()helper to centralize filtering logic (including extension-protocol detection). - Updates
processWindowErrorEvent()to use the new filter and simplifies config access. - Makes the Vitest
window.configmock more realistic and adds unit tests for the new filter helper.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
web_src/js/vitest.setup.ts |
Adjusts window.config.assetUrlPrefix mock to '/assets' to better match runtime. |
web_src/js/modules/errors.ts |
Adds isGiteaError() and switches global error processing to use it. |
web_src/js/modules/errors.test.ts |
Adds targeted unit tests for isGiteaError(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address review feedback: reject errors where filename points to a non-Gitea URL (not matching asset prefix or page origin). Add tests for external and same-origin inline script filenames. Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
1. Filter out errors that contain `chrome-extension://` etc protocols 2. Extract filtering into its own function and test it 3. Fix the `window.config.assetUrlPrefix` mock, guaranteed to end with `/assets` 4. Remove useless `??` and `?.` for properties that always exist Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com>
Backport #37148 by @silverwind 1. Filter out errors that contain `chrome-extension://` etc protocols 2. Extract filtering into its own function and test it 3. Fix the `window.config.assetUrlPrefix` mock, guaranteed to end with `/assets` 4. Remove useless `??` and `?.` for properties that always exist --- This PR was written with the help of Claude Opus 4.6 Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com>
* main: Make Markdown fenced code block work with more syntaxes (go-gitea#37154) Remove unneeded doctor sub-commands (go-gitea#37156) Report structurally invalid workflows to users (go-gitea#37116) Replace `rollup-plugin-license` with `rolldown-license-plugin` (go-gitea#37130) Clean up and improve non-gitea js error filter (go-gitea#37148)
works somehow it is because of 1pw lol |
chrome-extension://etc protocolswindow.config.assetUrlPrefixmock, guaranteed to end with/assets??and?.for properties that always existThis PR was written with the help of Claude Opus 4.6