-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime warning about "Could not create web worker(s)..." #853
Comments
Had this too. Once I changed the useWorkerFactory to use module paths that can be resolved, it worked for me |
Could you expand on that? What did you change more precisely, and was it with angular and/or webpack? I've tried messing around with webpack config and aliases, and changing the paths in the |
Due to the way we bundle the url that was passed / calculated was wrong. Then the worker creation failed I debugged to to find out the url it was requesting and then figured out my app does not deliver it due to the way we bundle |
Okay. I'll try looking further into that. Thanks. Do you remember if there was any particular piece of documentation for webpack (or other) that helped you? Or was it just about finding what the browser requests, and where webpack (or your bundler) puts the files, and making them match? |
yes i debugged the url, and then checked where it actually lands, and then passed the correct url |
Hmm, as far as I can tell, it resolves correctly. export * from '@codingame/monaco-vscode-api/workers/editor.worker'; And the So URLs not resolving might not be my issue... |
It's weird. It appears in the network tab, but as 'pending' and with 0 B transferred, but if I doubleclick it, I can get the content in a new tab with no problem. Only thing I can think of now is that something in the headers, that isn't present when loading it in a new tab, is causing the server not to respond... |
the -es.js file seems self contained the other one just does |
Hmm, I don't have a -es.js file in Now I tried using the |
Hi @jhk-mjolner I just pushed an update to our verification examples including the webpack one (after x.3.0 release). There it works. Please, take a look at the webpack config and especially the worker related things: And very important: Do not install the original You can even remove import * as monaco from '@codingame/monaco-vscode-editor-api'; |
Thanks. I've uninstalled the In the verify/webpack project, I noticed that the loaded worker js file is a clearly webpack bundled file called Except for occasionally breaking things more, the changes I tried with the webpack config didn't change that it was output and fetched as an untransformed I don't know why webpack does that wrong, or how to change it. |
@jhk-mjolner the one thing I can add here is that I have experienced that custom webpack used by ng behaves differently then direct webpack and that may explain your observation. |
Hmm. With the latest version of the codingame packages I cannot find editorWorker-es.js |
solved it by bundling myself
|
@cdietrich I dropped those pre-bundled versions. It was a helpful in the past, but it is better to define something on user level especially with regard to local bundling. |
I've now tried creating a new empty Angular project, installed and used It seems my next option is to manually build the workers in a separate step, as @cdietrich is doing. Though I'm not sure how complicated it's going to be, seeing that I'm not fully controlling webpack, just providing extra configuration, and not using esbuild like it seems @cdietrich is doing. @kaisalmen, would it be possible (and simple) to bring the pre-bundled versions back just to support angular with webpack? User-bundled workers can still be the suggestion and recommendation, but currently things are broken for angular both with webpack and with esbuild. Maybe pre-bundled workers could be an easy way to make it work at least for angular with webpack? |
@jhk-mjolner yes, I will bring back the pre-bundled workers with #863 |
I saw that #863 is merged, and a x.4.0 versions have been released. Is the pre-bundling not included in x.4.0, are the pre-bundled versions available at other paths, or am I misunderstanding something? |
did you see ./node_modules/monaco-editor-wrapper/dist/workers/editorWorker-es.js |
No, I hadn't found that. Thanks! 🙂 I'm trying to import it like
Which it obviously can't import in the browser. I tried messing around with the worker and module related webpack configurations again, but nothing I try seem to fix it. |
Thanks for the suggestion! I'm not happy about having to do the manual step of copying it when the |
maybe you can do something in webpack as we do in esbuild
|
Yeah, I was trying something like that with 'assets' in edit: for future reference, I got it working with the following glob in
and imported as |
Since I got it working with copying the editorWorker-es.js file, I guess we can close this issue. |
Full warnings I get are
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
I don't think I'm getting the UI freezes it mentions, but the warning appeared when I changed from using the
buildWorkerDefinition()
method from themonaco-editor-workers
package to using the newuseWorkerFactory
method of building/initializing workers. Or it could be from updating themonaco-languageclient
packages, I'm not sure, but I don't think I can usemonaco-editor-workers
with the newermonaco-languageclient
packages.I'm using the
monaco-editor-wrapper
, but the warnings also appear in a branch I have where I'm not using the wrapper, so it doesn't appear to be related to that.It seems to be only about the
simpleWorker
, and it happens even if I don't include the'TextEditorWorker'
and'TextMateWorker'
functions underworkerLoaders
for theuseWorkerFactory()
call like it is hereI'm using Angular and Webpack, and these versions of monaco packages:
monaco-editor: 0.52.2,
monaco-editor-wrapper: 6.2.5
monaco-languageclient: 9.2.5
A bit more from the console log in case it's relevant:

My code where I'm using monaco editor can be seen here
I'll reiterate that I'm not seeing errors or anything breaking that I'm aware of, but I'm guessing it's not intended.
The text was updated successfully, but these errors were encountered: