Repository navigation
standalone-typescript-language-features: is simulateWorkerReady the wrong way to configure getWorker, and is the 36.2.2/36.2.3 binder regression known?
#824
Replies: 1 comment 1 reply
The worker logic changed quite a lot this year, with monaco-editor being often late compared to VScode changes Anyway, I would recommend only using getWorkerUrl & getWorkerOptions, which are working for all workers (the editor worker, the language workers AND the extension host worker, loaded from an iframe) Also, it uses a blob worker loading that script to support cross-origin workers. And finally, it adds the I'm not sure how it works in monaco-editor alone 🤔
Indeed, it seems that it's caused by the rollup update, especially rollup/rollup#6065 which analyse the source code more in depth and now detects for some reason this method as pure 🤔 They've immediately released a patch though to revert that behavior. Rollup was updated in this repo and it's already building, a new version will be deployed soon with the fixed version |
Uh oh!
There was an error while loading. Please reload this page.
Two related questions from a non-workbench ("standalone") setup using
@codingame/monaco-vscode-standalone-typescript-language-features.1. Are we doing something wrong with
MonacoEnvironment.getWorker?internal/common/workers.js'screateWebWorker()waits for the worker topostMessage({type: "vscode-worker-ready"})before using it. That signal is only ever sent by the library's owngetWorkerUrlbootstrap blob — a worker we construct ourselves viaMonacoEnvironment.getWorkernever sends it, sogetSyntacticDiagnostics/getSemanticDiagnosticshang forever:For comparison, the Getting Started guide's "Adding languages" section (for plain
monaco-editor, before the VSCode-API layer is introduced) showsgetWorkerreturningnew tsWorker()directly with no handshake of any kind needed — so this requirement seems specific tostandalone-typescript-language-features's owncreateWebWorker, not something inherent to how Monaco workers normally work.Our workaround is to manually dispatch that message ourselves, deferred so it fires after the library's own listener attaches:
It works, but it relies on an internal implementation detail rather than a documented API. The demo's
setup.common.tsusesgetWorkerUrl/getWorkerOptionsinstead ofgetWorkerfor its workers, but never configures a"typescript"/"javascript"worker that way either (workbench mode gets TS support from the extension-host language server instead), so there's no reference example for this specific case. IsgetWorkereven supposed to work here, or isgetWorkerUrlrequired — and if so, could you point to a working example for a non-esbuild bundler? (We tried the demo'sgetWorkerUrl/.url-on-worker-instance pattern and it didn't work under Vite 8/Rolldown —Workerinstances there have no.url/.optionsproperties.)2.
36.2.2/36.2.3regression: bundled compiler never binds source filesSeparately, we bisected a real regression:
getSemanticDiagnosticsthrowsTypeError: Cannot read properties of undefined (reading 'get')on every version from36.2.2onward, but works correctly on36.2.0(and every version back to25.0.0).npm diffbetween36.2.0and36.2.2showscreateBinder()(TypeScript's own binder) was deleted from the bundledtypescriptServices.js, andbindSourceFile()reduced to a no-op:Is this a known issue? We've pinned to
36.2.0as a workaround. Happy to open this as a separate bug report with a minimal repro if that's more useful than a discussion thread.All reactions