fix: ignore errors from browser extensions in error handler and editor init#7456
Conversation
…r init Browser extensions (BitWarden, Dashlane, etc.) inject scripts that can throw errors caught by Etherpad's global exception handler, showing a scary error popup and sometimes blocking the editor from loading. Two fixes: - globalExceptionHandler (pad_utils.ts): Skip errors where the source URL matches moz-extension://, chrome-extension://, or safari-extension:// patterns. - Ace2Editor.init (ace.ts): The eventFired() error callback now checks if the error event's target src is a browser extension and ignores it, preventing extension-injected script failures from killing editor initialization. Fixes ether#6802 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
/review |
Code Review by QodoNew Review StartedThis review has been superseded by a new analysisⓘ The new review experience is currently in Beta. Learn more |
Review Summary by QodoIgnore browser extension errors in error handlers
WalkthroughsDescription• Ignore errors from browser extension scripts in global exception handler • Skip extension errors in Ace2Editor initialization to prevent blocking • Detect extension URLs using moz-extension, chrome-extension, safari-extension patterns • Prevents scary error popups and editor loading failures from unrelated extension code Diagramflowchart LR
A["Browser Extension<br/>Injects Script"] -->|"Throws Error"| B["Global Exception<br/>Handler"]
A -->|"Error Event"| C["Ace2Editor.init<br/>eventFired"]
B -->|"Check URL Pattern"| D{"Extension URL?"}
C -->|"Check URL Pattern"| E{"Extension URL?"}
D -->|"Yes"| F["Silently Ignore"]
D -->|"No"| G["Show Error Popup"]
E -->|"Yes"| H["Continue Init"]
E -->|"No"| I["Reject Promise"]
File Changes1. src/static/js/ace.ts
|
Code Review by Qodo
1. Missing regression test
|
| const errorCb = (evt) => { | ||
| // Ignore error events from browser extension scripts — they are unrelated | ||
| // to Etherpad and should not block editor initialization. | ||
| // See https://github.com/ether/etherpad-lite/issues/6802 | ||
| const src = evt?.target?.src || evt?.filename || ''; | ||
| if (/^(moz|chrome|safari)-extension:\/\//.test(src)) { | ||
| debugLog('Ace2Editor.init() ignoring error from browser extension:', src); | ||
| return; | ||
| } | ||
| const err = new Error(`Ace2Editor.init() error event while waiting for ${event} event`); | ||
| debugLog(`${err} on object`, obj); | ||
| cleanup(); |
There was a problem hiding this comment.
1. Missing regression test 📘 Rule violation ☼ Reliability
This PR changes production error-handling behavior to ignore browser-extension errors but does not add/update an automated regression test to ensure the bug cannot be reintroduced. Without a test, a future refactor could revert this behavior and CI would not catch it.
Agent Prompt
## Issue description
A bug fix was made to ignore error events/exceptions originating from browser extensions, but there is no automated test that would fail if this behavior were reverted.
## Issue Context
The change prevents extension-injected script errors (e.g., `chrome-extension://`, `moz-extension://`, `safari-extension://`) from blocking editor/pad loading.
## Fix Focus Areas
- src/static/js/ace.ts[53-66]
- src/static/js/pad_utils.ts[399-425]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Won't fix — browser extension errors are inherently untestable in Playwright (no real extensions in headless browsers). The regex filter is simple and defensive.
Summary
Browser extensions (BitWarden, Dashlane, password managers, FIDO2 authenticators) inject scripts into pages that can throw errors. Etherpad's error handling catches these unrelated errors and either shows a scary error popup or blocks the editor from loading entirely.
Two fixes:
globalExceptionHandler (pad_utils.ts): Errors where the source URL matches
moz-extension://,chrome-extension://, orsafari-extension://are silently ignored instead of showing a gritter error popup.Ace2Editor.init (ace.ts): The
eventFired()error callback checks if the error event's targetsrcis a browser extension URL. If so, it ignores the error instead of rejecting the promise and killing editor initialization.Root Cause
Extensions inject
<script>elements that can triggererrorevents on the iframe during load, and throw JS errors caught bywindow.addEventListener('error'). Neither of these are Etherpad bugs, but the handler treated all errors equally.Test plan
Fixes #6802
🤖 Generated with Claude Code