Skip to content

fix(monaco-graphql): support monaco-editor >= 0.56 - #4463

Open
lukasbash wants to merge 1 commit into
graphql:mainfrom
lukasbash:fix/monaco-editor-0.53-worker-loading
Open

lukasbash wants to merge 1 commit into
graphql:mainfrom
lukasbash:fix/monaco-editor-0.53-worker-loading

Conversation

@lukasbash

Copy link
Copy Markdown

Fixes #4382.

monaco-editor 0.53+ rewrote how custom workers are created and dropped
the exports field escape hatch monaco-graphql relied on for its deep
imports, breaking every monaco-graphql install on modern monaco-editor.

Two independent breaks bundled together

  1. editor.createWebWorker() no longer loads a worker by moduleId
    or delivers createData.
    The type is now
    { worker: Worker | Promise<Worker> } - the caller is expected to
    construct the worker itself. WorkerManager now builds the worker via
    MonacoEnvironment.getWorker() and configures it through a new
    GraphQLWorker#initialize() RPC call once the worker is ready,
    instead of via constructor args that are no longer transported.

  2. graphql.worker.ts's bootstrap wrapped initialize() inside an
    extra onmessage handler.
    monaco-editor's client now sends a
    throwaway ping message immediately followed by the real
    $initialize handshake; the extra wrapper consumed the ping and
    only called initialize() on the next message - the real handshake -
    one message too late for its reply to reach the client, hanging
    every worker RPC call forever.
    monaco-editor/editor/editor.worker's own bootstrap calls
    initialize unwrapped for the same reason; mirrored that here.

Also updates the now-relocated monaco-editor/esm/vs/... deep imports
(the exports field dropped the old paths), the deprecated
languages.json.jsonDefaults reference, and bumps the monaco-editor
peer range to >= 0.56.0.

This is a breaking change for consumers on monaco-editor < 0.53 -
no attempt is made to support both API shapes at once, matching the
scope implied by #4382.

Test plan

  • Full monorepo tsgo --build passes clean
  • Verified end-to-end against a real app (React + Vite, native
    MonacoEnvironment.getWorker worker setup, no
    vite-plugin-monaco-editor) on monaco-editor 0.56.0: GraphQL
    autocomplete, hover, and validation all round-trip through the
    worker correctly - confirmed via instrumented worker calls that
    the full WorkerManager -> createWebWorker -> initialize() -> doValidation() chain resolves and returns real diagnostics
    (previously threw Missing requestHandler or method: doValidation
    / doComplete / doHover on every call)
  • Package's own test suite (vitest run) - not run in this pass,
    happy to run if maintainers want it before review

monaco-editor 0.53+ rewrote how custom workers are created and lost the
`exports` field escape hatch monaco-graphql relied on for deep imports,
breaking every monaco-graphql install on modern monaco-editor. Fixes graphql#4382.

Two independent breaks bundled together:

1. `editor.createWebWorker({ moduleId, label, createData })` no longer
   loads a worker by moduleId or delivers createData - the type is now
   `{ worker: Worker | Promise<Worker> }`, and the caller is expected to
   construct the worker itself. WorkerManager now builds the worker via
   `MonacoEnvironment.getWorker()` and configures it through a new
   `GraphQLWorker#initialize()` RPC call once the worker is ready, instead
   of via constructor args that are no longer transported.

2. `graphql.worker.ts`'s bootstrap wrapped `initialize()` inside an extra
   `onmessage` handler. monaco-editor's client now sends a throwaway
   ping message immediately followed by the real `$initialize` handshake;
   the extra wrapper consumed the ping and only called `initialize()` on
   the next message - the real handshake - one message too late for its
   reply to reach the client, hanging every worker RPC call forever.
   `monaco-editor/editor/editor.worker`'s own bootstrap calls `initialize`
   unwrapped for the same reason; mirrored that here.

Also updates the now-relocated `monaco-editor/esm/vs/...` deep imports
(exports field dropped the old paths), the deprecated
`languages.json.jsonDefaults` reference, and bumps the monaco-editor
peer range to `>= 0.56.0`. This is a breaking change for consumers on
monaco-editor < 0.53 - no attempt is made to support both API shapes
at once.
@changeset-bot

changeset-bot Bot commented Aug 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c26e36a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

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.

Support monaco-editor@0.53+

1 participant