microsoft / microsoft/monaco-editor
[Bug] Can't automatic init webworker
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Not applicable
Monaco Editor Playground Code
Not applicable
Reproduction Steps
- init a vue project (using
npm create vue) - intall monaco editor (using
npm install monaco-editor@0.48.0) - define a new theme, like:
monaco.editor.defineTheme("logThemeDark", {
base: "vs-dark",
inherit: true,
rules: [],
colors: {
"editor.background": "#282C34",
"editor.lineHighlightBackground": "#2C313C",
},
});
- init editor to a dom
- run server and open website
- check console in DevTools
Actual (Problematic) Behavior
warning in console:
- chunk-KNE2EGB2.js?v=0f63c2c9:39565 Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq
- chunk-KNE2EGB2.js?v=0f63c2c9:39567 You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker
checked the faq, not opened with file:// (opened with http:// that served by vite)
(sorry for my poor english, i'm a chinese)
Expected Behavior
can create webworker successfully
Additional Context
platfrom:
- Window 11 24H2
browser:
- Chrome 124.0.6367.91 x64
- Edge 124.0.2478.67 x64 stable app beta channel
npm packages:
test-project@0.0.0 D:\projects\PCL-Community\PCL2-LogViewer-TE\test-monacoEdtior
├── @vitejs/plugin-vue@4.6.2
├── monaco-editor@0.48.0
├── vite@5.2.10
└── vue@3.4.26
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Vue/Vite reproduction using monaco-editor 0.48.0 and review the Monaco Editor FAQ for web worker setup. Investigate why the browser falls back to the main thread despite being served over HTTP; done means the worker initializes successfully without the console warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, vite
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100