pierrejeambrun opened a new pull request, #67352:
URL: https://github.com/apache/airflow/pull/67352
Stacked on top of #67316 (which contains the expand/collapse fix and
the \`server.origin\` change that made the worker URL accessible). The
diff against \`main\` will only show the single Monaco-worker commit
once #67316 lands; until then this PR carries those commits along.
#### What this fixes
#67342: in dev mode the browser console fills with
\`\`\`
TypeError: Cannot read properties of undefined (reading 'toUrl')
at FileAccessImpl.toUri (...)
at EditorSimpleWorker.\$loadForeignModule (...)
\`\`\`
every time a Monaco editor mounts (XComs, Audit Log, DAG code, ...).
Production builds are unaffected; this is dev-mode only.
#### Why
In dev mode the SPA shell is served by the airflow api-server while
Vite serves assets on a different origin. Vite's \`?worker\` import
generates \`new Worker(crossOriginUrl, { type: "module" })\` which the
browser refuses for cross-origin module workers — \`server.cors\` does
not help here, the Worker constructor itself rejects it ('Script at
<vite url> cannot be accessed from origin <api-server>'). Monaco then
falls back to 'main-thread workers'; that fallback path executes
\`\$loadForeignModule\` synchronously and resolves module IDs through the
non-existent AMD \`require.toUrl\`, throwing repeatedly.
#### Fix
Swap the \`?worker\` constructor imports for \`?url\` imports and build
workers from a same-origin Blob shim that simply re-imports the
resolved URL. The Blob URL lives on the page origin so the Worker
constructor accepts it, and the inner cross-origin \`import\` is allowed
by Vite's CORS response.
Closes #67342
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Opus 4.7)
Generated-by: Claude Code (Opus 4.7) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]