Code - Upgrade monaco-editor to 0.31.1 for the null-model worker guard - #4301
Code - Upgrade monaco-editor to 0.31.1 for the null-model worker guard#4301agalin920 wants to merge 3 commits into
Conversation
monaco-editor 0.25.2's JSONWorker.getFoldingRanges passes a null document straight into the language service when the model was disposed after the folding request was posted, which is the getText() crash in #3895. Upstream added the guard in 0.31.0. monaco-editor-webpack-plugin moves 4.2.0 -> 7.1.1 because 4.x peers only 0.25-0.28. react-monaco-editor stays at 0.47.0 and its peer on monaco-editor@^0.31.1, currently unsatisfied, becomes satisfied. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
QA Review — ✅ PASSValidates #3895: Error: Cannot read properties of null (reading 'getText')
Suggested Cypress coverage
|
|
On
Also worth recording since it is the other half of "does the 0.25→0.31 jump break a consumer": every monaco symbol referenced anywhere in On the suggested race spec: declining it deliberately, same reasoning that closed #3909. The race has never reproduced on demand — it has no confirmed reproduction from the reporter, from Sentry, or from us — so a spec that rapidly switches files and asserts no error appears would pass identically with this bump reverted, which makes it a spec that cannot fail rather than coverage. The falsifiable check is on the artifact instead, and it was made: |
Code Review — ✅ No blockers |
Negative QA🔴 Code editor crashes to an error boundary on every file open after the monaco-editor 0.31.1 bumpType: regression from this PR
Expected: The Monaco editor loads the file content with the custom "parsleyDark" theme applied, as before the version bump. Also checked and working correctly
|
…r the editor monaco 0.31's StandaloneTheme.tokenTheme getter reads themeData.colors["editor.foreground"] without guarding, so a defineTheme call with no colors key throws on the first setTheme. That is editorDidMount, so every file opened in the Code app landed in the ErrorBoundary. colors is a required member of IStandaloneThemeData on 0.25.2 too; monaco simply never read it before, and MonacoSetup.js is .js so tsc never checked it. Empty is behaviour-preserving: both lookups stay undefined and no default token rule is synthesised, so tokens render as they did on 0.25.2. Adds cypress/e2e/code/editor.spec.js because no existing spec asserted the editor renders - sidebar.spec.js stops at location.pathname and actions.spec.js exercises the diff editor. The new spec fails without this fix and passes with it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Confirmed and fixed in Root cause, exactly as reported. monaco 0.31 added this to const editorForeground = this.themeData.colors['editor.foreground'];Unguarded. Worth recording: Fix is On why the existing suite stayed green — that is the more useful half of this finding. No spec asserted the Code editor renders. Re-verified locally on |
Coverage ReportOverall Coverage
Changed Files Coverage
|
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Closes #3895
monaco-editor0.25.2'sJSONWorker.getFoldingRangespasses the result of_getTextDocument(uri)straight into the JSON language service without checking it. When a folding request has been posted to the worker and the model is disposed before the worker answers — closing theJsonViewerdialog, or switching files in the Code app, both of which dispose the model — that lookup returnsnull, the language service callsdocument.getText(), and the rejection reaches Sentry throughonUnexpectedError. That is the reported frame. Upstream addedif (!document) { return []; }to the method in 0.31.0; 0.30.1 is the last unguarded release. This bumpsmonaco-editorto ^0.31.1, which carries the same guard for the CSS worker'sgetFoldingRangesandfindDocumentHighlights(the sibling crash in the closed #3909), and it is the substance of #4254.monaco-editor-webpack-pluginmoves 4.2.0 → 7.1.1 because 4.x peers only 0.25–0.28;react-monaco-editorstays at 0.47.0, and its peer onmonaco-editor@^0.31.1— whichnpm lscurrently reports as unsatisfied — becomes satisfied. No application code changes: none of the twelve monaco symbols used insrc/is in the 0.25→0.31 breaking set, and the three feature names in the webpack allowlist that 0.31.1 no longer knows (colorDetector,goToDefinitionCommands,goToDefinitionMouse) are already dead against the 4.2.0 table today, so nothing changes there either. The guard is present in the emitted artifact, not just innode_modules—build/json.worker.js:19456. The whole dependency delta is these two packages; no transitive version moves across the other 1,528. The dev bundle gets smaller: 75.1 MB → 69.9 MB (−5.1 MB, −6.9%), mostlyts.worker.jsandvendors.js.No
reviewercold pass ran on this diff — this session's harness ruled out subagents, so the review gate indocs/definition-of-done.md§5 was not met and the diff has been read only by the context that wrote it.