microsoft / microsoft/monaco-editor

[Bug] 0.56.0 browser CSP violation

Open
#5,462 1 comment 0 reactions 1 assignee View on GitHub

@hediet is already working on this.

Since Aug 28, 2026.

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?
Monaco Editor Playground Link

As also mentioned in #5405, besides the build issue, v0.56.0 browser-esm-esbuild build generates a CSP violation warning in operation. Judging by the error, it looks like the editor tries to generate a worker on the fly. If it is a separate file, it would not have the issue.

There was no such issue in v0.55.1.

Content-Security-Policy: The page’s settings blocked a worker script (worker-src) at blob:moz-extension://f5...11/52...22 from being executed because it violates the following directive: “script-src 'self' 'wasm-unsafe-eval'”

Uncaught (in promise)
error { target: Worker, isTrusted: true, srcElement: Worker, eventPhase: 0, bubbles: false, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, timeStamp: 388, … }

The blob content:

/editorWorkerService/globalThis._VSCODE_NLS_MESSAGES = undefined;globalThis._VSCODE_NLS_LANGUAGE = undefined;globalThis._VSCODE_FILE_ROOT = undefined;const ttPolicy = globalThis.trustedTypes?.createPolicy('defaultWorkerFactory', { createScriptURL: value => value });globalThis.workerttPolicy = ttPolicy;try {await import(ttPolicy?.createScriptURL("moz-extension://f5...11/lib/monaco-editor/vs/editor/editor.worker.js#editorWorkerService") ?? "moz-extension://f5...11/lib/monaco-editor/vs/editor/editor.worker.js#editorWorkerService");} catch (err) { console.error("Failed to load worker script for label: editorWorkerService.\nEnsure your bundler properly bundles modules referenced by "new URL('...?esm', import.meta.url)".", err); throw err; }globalThis.postMessage({ type: 'vscode-worker-ready' });/editorWorkerService/

Monaco Editor Playground Code

Reproduction Steps

No response

Actual (Problematic) Behavior

No response

Expected Behavior

No response

Additional Context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.