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

Web extension broadcomMFD.hlasm-language-support no longer works #220171

Closed
mihailik opened this issue Jul 6, 2024 · 27 comments
Closed

Web extension broadcomMFD.hlasm-language-support no longer works #220171

mihailik opened this issue Jul 6, 2024 · 27 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member extension-host Extension host issues regression Something that used to work is now broken web Issues related to running VSCode in the web

Comments

@mihailik
Copy link
Contributor

mihailik commented Jul 6, 2024

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version:
    Version: 1.91.0 (user setup)
    Commit: ea1445c
    Date: 2024-07-01T18:52:22.949Z
    Electron: 29.4.0
    ElectronBuildId: 9728852
    Chromium: 122.0.6261.156
    Node.js: 20.9.0
    V8: 12.2.281.27-electron.0
    OS: Windows_NT x64 10.0.19045

  • VS Code Version loaded for debugging:
    Version: 1.92.0-insider
    Commit: 82104a3
    Date: 2024-07-05T00:00:00.000Z
    Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36

Steps to Reproduce:

  1. Open an existing web extension codebase, or generate a brand new one with yo code as described in the official documentation at Web Extensions | Visual Studio Code Extension API
  2. Run npm install if necessary.
  3. Run npm run run-in-browser to debug Web Extension
  4. Hobbled non-functional version of VSCode is loaded, with disconnected "mount" and the web extension not loaded (see screenshot below)
  5. Clicking in the file tree crashes with unserious error messages. DevTools console looks disastrous (see below).

Unable to resolve resource vscode-test-web://mount/

image

This does 𝗻𝗼𝘁 look like vscode-test-web issue

The session fails on new, and on old well-used versions of @vscode/test-web

  • The example in /vscode-extension-samples/helloworld-web-sample that uses v0.22 fails.
  • My own repo fails - tested historical commits with v0.32, v0.52, even tried the very latest v0.56
  • Brand new scaffolded extension pointing to v0.55 fails

Also tried on MacOS (M1), on Ubuntu (arm64 VM) and Windows 10.

Never works.

@bpasero bpasero added info-needed Issue requires more information from poster and removed triage-needed labels Jul 7, 2024
@bpasero bpasero added this to the July 2024 milestone Jul 7, 2024
@bpasero
Copy link
Member

bpasero commented Jul 7, 2024

There was a recent change to our NLS story that requires vscode-test-web to install a newer version. Can you check what version of "@vscode/test-web" you have installed and make sure its updated to latest?

@aeschli I wonder how we can communicate this to extension authors that they will have to update, besides putting release notes.

@mihailik
Copy link
Contributor Author

mihailik commented Jul 7, 2024

As mentioned above, tried with these versions, including the latest:

v0.22
v0.32
v0.52
v0.55
v0.56 <-- latest

@mihailik
Copy link
Contributor Author

mihailik commented Jul 7, 2024

And I'd love to help you guys with fixing, give me some clues what's changed with NLS.

I can see these, but they're quite terse on details.

NLS: decouple from loader (helps for ESM) #212542

Implement NLS without AMD loader #214588

nls follow up debt work #219265

I'll try to check out https://github.com/microsoft/vscode-test-web update references and see if it comes with any issues by itself. But hints and tips appreciated!

@mihailik
Copy link
Contributor Author

mihailik commented Jul 7, 2024

Aha! Clamping the VSCode to "stable" not "insiders" fixes it for vscode-test-web.

That's good enough to fix the immediate issue so I'll make a PR for vscode-test-web repo patch.

Still give me clues, I'd love to make a proper fix with whatever NLS shenanigans needing to change.

image

@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member regression Something that used to work is now broken web Issues related to running VSCode in the web and removed info-needed Issue requires more information from poster labels Jul 7, 2024
@bpasero
Copy link
Member

bpasero commented Jul 7, 2024

I can reproduce with a fresh extension, but I am not clear how my NLS changes impact this, given we pushed a fix for that 🤔

@mihailik
Copy link
Contributor Author

mihailik commented Jul 7, 2024

PR to vscode-test-web repo to unblock the functionality by falling back onto stable -

Clamp VSCode download to stable release until NLS issue on Insiders is fixed #129

At least my own development is unblocked, but I suspect others might appreciate it.

@bpasero
Copy link
Member

bpasero commented Jul 7, 2024

I think we would rather address the real issue.

@mihailik
Copy link
Contributor Author

mihailik commented Jul 7, 2024

Sure, I just thought one does not preclude another.

bpasero added a commit that referenced this issue Jul 8, 2024
The web worker is now using `importScript` directive in a data URL which is no longer the same `script-src` as the iframe when running built where we use `webEndpointUrlTemplate`. This breaks `vscode-test-web` that runs from `localhost` so we allow `http://localhost`
@bpasero bpasero closed this as completed in 6f18713 Jul 8, 2024
@vscodenpa vscodenpa added the unreleased Patch has not yet been released in VS Code Insiders label Jul 8, 2024
@vscodenpa vscodenpa added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jul 8, 2024
@bpasero bpasero added the author-verification-requested Issues potentially verifiable by issue author label Jul 9, 2024
@vscodenpa
Copy link

This bug has been fixed in the latest release of VS Code Insiders!

@mihailik, you can help us out by commenting /verified if things are now working as expected.

If things still don't seem right, please ensure you're on version b23e791 of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

Happy Coding!

@slavek-kucera
Copy link

slavek-kucera commented Jul 9, 2024

I am still getting errors:

09ac518b-16fa-4167-807a-4e021e8a04ae:1 Refused to load the script 'blob:http://v--09gskr5q7h8fetd36ifu8kdh2v08q87egl8od71vgvu9r06ame0s.localhost:3000/447093dc-785b-4ae1-8f63-7f861336850a' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' 'sha256-V28GQnL3aYxbwgpV3yW1oJ+VKKe/PBSzWntNyH8zVXA=' https: http://localhost:*". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

(anonymous) @ 09ac518b-16fa-4167-807a-4e021e8a04ae:1
(anonymous) @ 09ac518b-16fa-4167-807a-4e021e8a04ae:1
09ac518b-16fa-4167-807a-4e021e8a04ae:1 Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'blob:http://v--09gskr5q7h8fetd36ifu8kdh2v08q87egl8od71vgvu9r06ame0s.localhost:3000/447093dc-785b-4ae1-8f63-7f861336850a' failed to load.
    at blob:http://v--09gskr5q7h8fetd36ifu8kdh2v08q87egl8od71vgvu9r06ame0s.localhost:3000/09ac518b-16fa-4167-807a-4e021e8a04ae:1:410
    at blob:http://v--09gskr5q7h8fetd36ifu8kdh2v08q87egl8od71vgvu9r06ame0s.localhost:3000/09ac518b-16fa-4167-807a-4e021e8a04ae:1:415
(anonymous) @ 09ac518b-16fa-4167-807a-4e021e8a04ae:1
(anonymous) @ 09ac518b-16fa-4167-807a-4e021e8a04ae:1
Version: 1.92.0-insider
Commit: b23e791eb5afbd95f05aa24da7693ce89344a079
Date: 2024-07-09T05:03:50.549Z
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36

EDIT:
Would it be possible to add blob: data: to the script-src and connect-src? Seems to fix all my problems.

@slavek-kucera
Copy link

I think this is somehow related to my problem

const bootstrapFnSource = (function bootstrapFn(workerUrl: string) {

@bpasero
Copy link
Member

bpasero commented Jul 9, 2024

I would need a step by step instruction how to reproduce with your extension, please be detailed and assume I haver never used that extension or ran it.

aaronchucarroll pushed a commit to aaronchucarroll/vscode that referenced this issue Jul 10, 2024
…rosoft#221030)

The web worker is now using `importScript` directive in a data URL which is no longer the same `script-src` as the iframe when running built where we use `webEndpointUrlTemplate`. This breaks `vscode-test-web` that runs from `localhost` so we allow `http://localhost`
@slavek-kucera
Copy link

I steps to reproduce the problem:

  • go to insiders.vscode.dev
  • install the extension
  • create a new text file
  • change language mode to hlasm
  • start typing
    You should get diagnostics, completions etc. on stable version you do, on insiders the lsp server no longer starts.

I managed to find a workaround and in the process I discovered a few additional details.
The extension uses emscripten toolchain to produce wasm and js glue code that allows the language server to run in the browser.
Originally, the Worker hosting the language server was able to fetch and import the glue code and later on start additional Workers (to emulate threads) reusing this imported module.
In the Insiders version, this does not seem to be possible anymore and the browser refuses to start the nested Workers, because the first Worker creation is handled by the vscode code I posted above, which means the worker is running a code from a Blob URL and apparently losses the ability to start workers with any other scripts.

@bpasero bpasero reopened this Jul 10, 2024
@bpasero bpasero assigned alexdima and unassigned bpasero Jul 10, 2024
@bpasero bpasero removed author-verification-requested Issues potentially verifiable by issue author insiders-released Patch has been released in VS Code Insiders labels Jul 10, 2024
@bpasero
Copy link
Member

bpasero commented Jul 10, 2024

I can reproduce, though I do not fully understand why the Content-Security-Policy suddenly became so strict in the extension host iframe. Before my change, the Worker extension host was created directly as new Worker(url) in the iframe. After my change, the Worker is created with a Blob that has a importScript inside:

const blob = new Blob([[
`/*extensionHostWorker*/`,
`globalThis.MonacoEnvironment = { baseUrl: '${baseUrl}' };`,
// VSCODE_GLOBALS: NLS
`globalThis._VSCODE_NLS_MESSAGES = ${JSON.stringify(nlsMessages)};`,
`globalThis._VSCODE_NLS_LANGUAGE = ${JSON.stringify(nlsLanguage)};`,
`importScripts('${workerUrl}');`,
`/*extensionHostWorker*/`
].join('')], { type: 'application/javascript' });

The iframe has always set a CSP:

<meta http-equiv="Content-Security-Policy" content="
default-src 'none';
child-src 'self' data: blob:;
script-src 'self' 'unsafe-eval' 'sha256-V28GQnL3aYxbwgpV3yW1oJ+VKKe/PBSzWntNyH8zVXA=' https: http://localhost:*;
connect-src 'self' https: wss: http://localhost:* http://127.0.0.1:* ws://localhost:* ws://127.0.0.1:*;"/>

I can confirm that the adding blob: and data: to script-src allows your extension to run again.

@mihailik where do you see that you also need connect-src to be updated?

@bpasero bpasero assigned bpasero and unassigned aeschli Jul 10, 2024
@bpasero bpasero added the extension-host Extension host issues label Jul 10, 2024
@bpasero bpasero changed the title Web Extensions no longer work in dev mode Web extension no longer works Jul 10, 2024
@bpasero bpasero changed the title Web extension no longer works Web extension broadcomMFD.hlasm-language-support no longer works Jul 10, 2024
@slavek-kucera
Copy link

I assume that the connect-src question was directed at me - it might not be needed, it could have been an artifact of my debugging.

@mihailik
Copy link
Contributor Author

/verified

@mihailik
Copy link
Contributor Author

Totally works, no more apparent issues.

Though seeing some console outputs related to nls, not sure if it needs to be worrying?

Let me know if I should collect any more info on this one.

IMG20240710105431

And huge thanks for the fast turnaround, and a fix. You rock!!!

@bpasero
Copy link
Member

bpasero commented Jul 10, 2024

Thanks, I did not figure out that 2 different users are in this issue, so while the original issue seems resolved, there is still the issue with broadcomMFD.hlasm-language-support not working currently in insiders.

@slavek-kucera
Copy link

@bpasero I think this can be closed now.

@hediet hediet modified the milestones: July 2024, August 2024 Jul 26, 2024
@bpasero
Copy link
Member

bpasero commented Jul 26, 2024

@slavek-kucera did the change in #223153 help?

@slavek-kucera
Copy link

@bpasero Not sure, I've found a way to build the extension so that I don't encounter the problem anymore.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member extension-host Extension host issues regression Something that used to work is now broken web Issues related to running VSCode in the web
Projects
None yet
Development

No branches or pull requests

7 participants