Skip to content

fix(editor): register the drop service before any editor - #6017

Merged
norman-abramovitz merged 2 commits into
cloudfoundry:developfrom
nabramovitz:norm/fix/monaco-drop-service
Oct 15, 2026
Merged

norman-abramovitz merged 2 commits into
cloudfoundry:developfrom
nabramovitz:norm/fix/monaco-drop-service

Conversation

@nabramovitz

Copy link
Copy Markdown
Contributor

Opening a JSON editor (for example the JSON view of a service instance's parameters) and then any other editor logged [createInstance] DropIntoEditorController depends on UNKNOWN service treeViewsDndService in the browser console.

Cause: Monaco loads its JSON language support on first use. The module that starts the JSON worker (monaco-editor internal/common/workers.js) imports almost every editor feature as a side effect, drop-into-editor included. Monaco fixes its editor services once, when the first editor is created, so the drop feature's service registers too late and every editor created afterwards fails to start the feature. The curated Monaco subset (eba2569) left drop-into-editor out; the full build had registered it at startup. Monaco 0.55.1, 0.56.0 and 0.57.0 all ship the same side-effect imports, so neither upgrade introduced this.

The fix imports features/dropOrPasteInto/register.js with the subset, so the service is registered before any editor exists. About 4.5 kB moves from the JSON chunk to the editor chunk:

Chunk Before (raw / gzip) After (raw / gzip)
monaco-features 809.48 / 164.85 kB 814.12 / 165.63 kB
jsonMode 453.95 / 99.76 kB 449.75 / 98.66 kB

Tried: a new Monaco smoke test creates a plaintext editor, then a JSON editor (waiting for its diagnostics), then a third editor, and fails on any page error. Against the dev stack it failed with the exact error before the fix and passes after it. make check gate passes, including the production build budget.

Upstream: microsoft/monaco-editor#5507 reports the side-effect imports (as bundle bloat and features leaking into later editors), and microsoft/monaco-editor#5508 proposes the one-line fix; both are open without a maintainer response. microsoft/monaco-editor#5491 is the same crash with another service (ICodeLensCache). Until a release carries the fix, the other features the subset leaves out also attach to editors created after JSON loads; only this one needed a service.

Refs #6002 (found during its live runs).

Changelog fragment: changelog.d/0008-monaco-drop-service.md.

AI disclosure (RFC-0047): prepared with AI coding assistance; reviewed by the author.

The json language support loads on first use, and the module that
starts its worker (monaco-editor internal/common/workers.js) imports
most editor features as a side effect, drop-into-editor included. Its
treeViewsDndService then registers after the first editor has fixed
the editor services, so every editor created later logs
"DropIntoEditorController depends on UNKNOWN service
treeViewsDndService".

The curated subset (eba2569) left drop-into-editor out; the full
build had loaded it at startup. Import it with the subset so its
service is registered first. Monaco 0.55.1 through 0.57.0 ship the
same side-effect imports, so neither upgrade introduced this.

The editor chunk grows 4.6 kB (0.8 kB gzip) and the json chunk shrinks
4.2 kB (1.1 kB gzip).

The smoke test starts the services with one editor, loads json with a
second, and fails on any page error raised by a third.

@norman-abramovitz norman-abramovitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@norman-abramovitz
norman-abramovitz merged commit e62e89d into cloudfoundry:develop Oct 15, 2026
24 checks passed
@nabramovitz
nabramovitz deleted the norm/fix/monaco-drop-service branch October 24, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants