microsoft / microsoft/monaco-editor
[Bug] Requests to language workers (tsWorker/cssWorker..) result in 404 errors due to incorrect URLs. Happens even in a simple application. But only when urlArgs(for cache busting) are specified in require.config call.
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
No response
Monaco Editor Playground Code
Reproduction Steps
As the title suggests, problem can be replicated with a simple html page(even the "browser-amd-editor" sample). Just have to specify urlArgs for the require.config call.
`
require.config({
paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.2/min/vs' },
urlArgs: "ver=1"
});
require(['vs/editor/editor.main'], function () {
var editor = monaco.editor.create(document.getElementById('container'), {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
});
});
`
Replication steps:
-> Browse fiddle https://output.jsbin.com/fiyupox
-> Open dev tools -> Network tab -> notice the failed request to tsWorker.js
The request URL would be - https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.2/min/vs/bas/vs/language/typescript/tsWorker.js?ver=1, which is incorrect("/vs/bas" part gets added).
Actual (Problematic) Behavior
The requests to language workers result in 404 errors due to request url being incorrect.
Expected Behavior
The requests to language workers should not result in 404 errors.
Additional Context
Some code in editor.main.js seems to be doing some string manipulations with the request urls and ending up injecting part a substring of URL constant - 'vs/base/worker/defaultWorkerFactory.js', resulting in an incorrect URL.
This appears like a serious issue. The urlArgs are for cache busting, but we can do away with putting the version in the paths instead. But its unsure if the problematic code can cause any other issues or can happen in other conditions too.
I know its frowned upon to ask ETAs, but some information regarding the likelihood of this getting fixed in near future would be much appreciated.
Note: Something similar(i.e problems when urlArgs are specified) was already raised - https://github.com/microsoft/monaco-editor/issues/4310. But the problem statement in that issue was that the urlArgs were not always respected. That issue does not appear to be using language workers provided with monaco-editor. If they did, same problem would show up. If this is going to be closed as a duplicate, please do ensure that problem mentioned here(language worker requests resulting in 404 errors) is fixed too.
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
Reproduce the failure with the browser-amd-editor sample or the linked JS Bin, setting urlArgs in require.config, and inspect the failed tsWorker.js request. Start by tracing the URL handling in editor.main.js and the worker path mentioned in defaultWorkerFactory.js. Done means language-worker requests use correct URLs and no longer return 404 errors when urlArgs is present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100