Unexpected usage exception when using `handlebars`, `razor`, `scss` or `less`
See original GitHub issueI just got “Uncaught Error: Unexpected usage” myself. I found that there are so many issues and nobody seems to care. I looked into it and the root cause seems to be too simple to be true?
- This always passed
null
asforeignModule
argument https://github.com/microsoft/vscode/blob/b449c95a8460443ee6bf985bb6c8db63d395e6e6/src/vs/editor/editor.worker.ts#L30 - The
foreignModule
variable inside the scope is never changed, so the second constructor argument here is alwaysnull
too - This means
this._foreignModuleFactory
is always null as well https://github.com/microsoft/vscode/blob/b449c95a8460443ee6bf985bb6c8db63d395e6e6/src/vs/editor/common/services/editorSimpleWorker.ts#L342 - Which prevents this if block from being entered https://github.com/microsoft/vscode/blob/b449c95a8460443ee6bf985bb6c8db63d395e6e6/src/vs/editor/common/services/editorSimpleWorker.ts#L645
- And fall through to here https://github.com/microsoft/vscode/blob/b449c95a8460443ee6bf985bb6c8db63d395e6e6/src/vs/editor/common/services/editorSimpleWorker.ts#L662
@alexdima any idea why you did that (ignore the first worker message)? https://github.com/microsoft/vscode/commit/66091601a52d4f495e8b90c8c56283a5b1b07bd0
The issue can also be reproduced in the official ESM examples and it has likely been present from day one of ESM support. All you need to do is use a language that uses the generic worker, e.g. put handlebars
here https://github.com/microsoft/monaco-editor-samples/blob/c5586a25cfd069349b6242a3d140223cc3d9110c/browser-esm-parcel/src/index.js#L23
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Error "unexpected char '#' " with rendering Handlebars template
... variable delimiter ({{) is by using a variable expression. ... For example, to include handlebars syntax in a template, you can use...
Read more >Language Server Protocol Specification - 3.17
The protocol use the following definitions for integers, ... A position inside a document (see Position definition below) is expressed as a zero-based...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Nice, thank you
Thanks for looking into this.
Like I said, the official examples trigger the error (both
browser-esm-parcel
andbrowser-esm-webpack
). Otherwise I’d probably not have made such bold claims 😅Here are the detailed steps:
So far this is copied from the official example repo. Now update the language to one that needs a custom worker:
And now follow the official steps to build the parcel esm example
Visit http://localhost:9999/
Chromium
Firefox
Like I said this works equally for browser-esm-webpack, I just happen to use parcel for my projects.