Repository navigation
fix(monaco): stop reporting worker load errors after an editor closes - #335
Merged
Merged
Conversation
Monaco stops its editor worker when the last model closes, for example when the user opens a different system. If the worker script is still loading, Chrome raises a failed importScripts NetworkError on the window. Monaco removed its own listener first, so Angular sent the error to Sentry as unhandled. Wrap MonacoEnvironment.getWorker so each worker cancels its error events after terminate(). Errors from workers that still run are not changed. Fixes BACKOFFICE-4Q Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sentry BACKOFFICE-4Q: users who open a system and then quickly open another system get an unhandled
NetworkError: Failed to execute 'importScripts'foreditor.worker-DM0G1eFj.js.The worker URL is correct, and this is not a stale deploy. Monaco 0.54.0 has shipped the same worker file since April. The cause is a race on route change. Monaco stops its editor worker when the last model closes, and the settings field closes its model when the page changes. If the worker script is still downloading (in the Sentry event the user was on a mobile network), Chrome raises the failed
importScriptson the window. Monaco has already removed its own listener, so Angular's global error listener sent the error to Sentry. In the Sentry event, the error arrived 21 ms after the user clicked the next system.The fix: after
editor.mainloads,loadMonaco()wrapsMonacoEnvironment.getWorker. Each worker records whenterminate()is called and cancels itserrorevents after that, so they no longer reach the window. Errors from workers that still run are not changed.Proof: I ran a production build at
/backoffice/with the mock backend and delayededitor.workerby 3 s. Before the fix, the window got the same error as Sentry about 20 ms after the second route change. After the fix, the log showed the worker created, the route changed, the worker terminated 21 ms later, and the worker error cancelled, with no window error. The worker still computed diffs afterwards. I added a unit test for the stopped and running cases.bun run lintandbun run test:cipass (992 tests).Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved
Created with Claude Opus 5.5 in Claude Code (T3 Code).
🤖 Generated with Claude Code