Skip to content

fix(dashboard): bundle Monaco editor with inline workers to fix CORS - #4579

Open
koushik717 wants to merge 1 commit into
hatchet-dev:mainfrom
koushik717:fix/bundle-monaco-editor-v2
Open

fix(dashboard): bundle Monaco editor with inline workers to fix CORS#4579
koushik717 wants to merge 1 commit into
hatchet-dev:mainfrom
koushik717:fix/bundle-monaco-editor-v2

Conversation

@koushik717

Copy link
Copy Markdown
Contributor

Re-applies #4247 with a fix for the production CORS failure that caused the revert in #4478.

Root cause of the revert

The original PR used Vite's ?worker suffix, which emits each worker as a separate JS chunk fetched by URL at runtime. In production environments where assets are served with strict CORS headers, those cross-origin worker URL fetches are blocked by the browser, breaking JSON schema autocomplete.

What changed

Switched ?worker to ?worker&inline in monaco-environment.ts:

// before
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';

// after
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker&inline';
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker&inline';

?worker&inline bundles each worker as a base64 blob URL inside the main chunk. No cross-origin fetch occurs at runtime, so CORS headers on the asset server are irrelevant.

Everything else is unchanged from the original PR.

Testing

  • pnpm run typecheck - same pre-existing codegen errors as main, no new errors
  • Verified no separate worker chunk files are emitted (workers are inlined)
  • The trade-off: slightly larger main bundle vs. no CORS dependency

AI disclosure (per AI_POLICY.md): I used an AI coding assistant for parts of this change and reviewed/tested everything above myself before opening this PR.

Re-applies hatchet-dev#4247 with a fix for the production CORS failure that caused
the revert in hatchet-dev#4478.

The original PR used Vite's ?worker suffix, which emits workers as
separate JS chunks fetched by URL at runtime. In production environments
where assets are served with strict CORS headers, those cross-origin
worker fetches are blocked, breaking JSON schema autocomplete.

This version switches to ?worker&inline, which bundles each worker as a
base64 blob URL inside the main chunk. No cross-origin fetch occurs at
runtime, so CORS headers on the asset server are irrelevant.

Everything else is unchanged from the original PR: monaco-editor is a
direct dependency, loader.config({ monaco }) routes @monaco-editor/react
to the bundled instance, and MonacoEnvironment.getWorker wires up the
editor and JSON workers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

@koushik717 is attempting to deploy a commit to the Hatchet Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard Related to the Hatchet dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant