Skip to content
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

[Bug] v0.51.0 breaks for browser based imports #4654

Open
1 of 2 tasks
tobiu opened this issue Aug 26, 2024 · 12 comments
Open
1 of 2 tasks

[Bug] v0.51.0 breaks for browser based imports #4654

tobiu opened this issue Aug 26, 2024 · 12 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-core
Milestone

Comments

@tobiu
Copy link

tobiu commented Aug 26, 2024

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

No response

Monaco Editor Playground Code

No response

Reproduction Steps

upgrade from v0.50.0 to v0.51.0

Actual (Problematic) Behavior

v0.50.0 was including the script: editor/editor.main.nls.js.

this silently got removed in v0.51.0 without getting mentioned inside the release log:
e52ff42

after removing the script as well inside the Neo.mjs env, i encountered several errors and warnings:
Screenshot 2024-08-26 at 20 41 32

Expected Behavior

there should be no undocumented breaking changes in minor versions.

Additional Context

cross-reference ticket:
neomjs/neo#5822

@hediet hediet added bug Issue identified by VS Code Team member as probable bug editor-core labels Aug 29, 2024
@hediet
Copy link
Member

hediet commented Aug 29, 2024

This is because the blob context cannot load relative urls.
@bpasero as discussed, we should probably make these URLs absolute.

@hediet hediet added this to the August 2024 milestone Aug 29, 2024
@tobiu
Copy link
Author

tobiu commented Aug 31, 2024

i looked a bit more into it. using v0.50.0:
Screenshot 2024-08-31 at 11 54 29

i assume the monaco worker name is "javascript". we do not see the neo workers here, since we are inside the shared workers mode of the framework.

what definitely changed with v0.51.0 is that monaco is trying to use importScripts. now this is a problem, since we are inside a JS module scope. in this context, monaco should stick to use import, since importScripts can not work.

makes sense?

off topic:
we have the multi-window support (without a native shell) fully working inside the Neo.mjs framework. so we can move the preview mode (mounting the widgets which get described inside the monaco editor) into different browser windows. we could also move multiple monaco editor instances into multiple windows, and they can still communicate. if it is a backlog item for you to also support multi-window, we can connect. you could save a lot of time with looking into the neo source code (MIT licensed).
Screenshot 2024-08-31 at 11 59 04

@bpasero
Copy link
Member

bpasero commented Sep 3, 2024

Potential fix: microsoft/vscode@634933e

@tobiu
Copy link
Author

tobiu commented Sep 21, 2024

I just tried it out in my use-case with v0.52.0. Not sure if the hotfix-candidate was already in there.

If so, it did not work:
Screenshot 2024-09-21 at 23 27 32

As mentioned inside my last comment: I really think the main issue is that importScripts() can not work inside a JavaScript module based setting. So we need dynamic imports => import() instead for this context. I recommend to take a closer look into your isESM check, since it is already there, just not hitting true.

You are welcome to ping me, in case you need help. We could do a quick screen-sharing session to enable you to run my use-case locally.

@MaxenceMouchard
Copy link

MaxenceMouchard commented Sep 30, 2024

Same error using monaco-editor-webpack-plugin 7.1.0 under monaco 0.52.0
@aiday-mar The task goes into the backlog? How are we supposed to handle this? I don't use any overrides about worker or url's, for my purposes, this is a blocker bug.

@JMGomes
Copy link

JMGomes commented Oct 5, 2024

Same Issue here. I'm blocked from use the latest versions due to this.

@IMax153
Copy link

IMax153 commented Oct 17, 2024

We in the Effect-TS org have also started experimenting with re-writing our playground (which leverages Monaco) to be bundled with Vite instead of dynamically loaded from a CDN.

While we are able to successfully run our playground, the issue that @tobiu described in great detail with import vs importScripts is blocking us from being able to register a custom TS worker with Monaco client side.

@GKersten
Copy link

@aiday-mar I notice this issue did move to the backlog, we had to downgrade to Monaco v0.50 to prevent this error in the meantime. Is there any way to prevent this error or suggested work around to allow for an upgrade?

@arnoudkooi
Copy link

I feel this issue is also related to the issue I am facing when trying to upgrade from 0.43.0 to 0.52.0 in my browser extension.
I get errors like below, not exactly sure, but could it be Manifest v3 does not allow loading script with the workerMain.js#javascript syntax. Trying to modify the content security policy does not work, as that does not allow loosening the setting like object-src 'self';

Refused to load the script 'chrome-extension://iimpebfldpbfipbodemijjbfblmkhoeh/js/monaco/vs/base/worker/workerMain.js#javascript' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' ". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback

And

Refused to load the script 'chrome-extension://iimpebfldpbfipbodemijjbfblmkhoeh/js/monaco/vs/base/worker/workerMain.js#javascript' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' http://localhost:* http://127.0.0.1:*". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

@straakaa
Copy link

Hello,
any update? I also can't upgrade to latest.

Its-treason added a commit to Its-treason/bruno that referenced this issue Nov 18, 2024
@x-etienne
Copy link

Same problem with 0.52.0

@MaxenceMouchard
Copy link

I would add that your Monaco Editor playground is also affected by this bug ...
https://microsoft.github.io/monaco-editor/playground.html?source=v0.52.0#example-creating-the-editor-hello-world

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug editor-core
Projects
None yet
Development

No branches or pull requests

16 participants