Skip to content

fix: load the graph again in production builds - #202

Merged
polyrainbow merged 1 commit into
mainfrom
fix/nested-worker-build
Nov 6, 2026
Merged

polyrainbow merged 1 commit into
mainfrom
fix/nested-worker-build

Conversation

@polyrainbow

Copy link
Copy Markdown
Owner

Summary

Since the Vite 8.3 upgrade (#196), a production build cannot load a graph: the note list spins forever. The notes worker starts the subwaytext parser pool from a ?worker&url import, and Vite 8.3 no longer writes that asset out when it is imported from inside a worker. The URL points at a file that does not exist, the parser workers never start, and every graph read rejects with undefined. The dev server, and with it the Playwright suite, is unaffected.

 // src/lib/notes/DatabaseIO.ts
-import subwaytextWorkerUrl from "../subwaytext/index.js?worker&url";
 …
-new Worker(subwaytextWorkerUrl, { type: "module" });
+new Worker(
+  new URL("../subwaytext/index.ts", import.meta.url),
+  { type: "module" },
+);

vite.config.ts gains referencedScriptsExistPlugin: after writing the bundle, it fails the build if any emitted script refers to an /assets/*.js file that was not written. CLAUDE.md notes the trap next to the existing MessagePort.start() gotcha.

Evidence

  • Before: npm run build on main emits assets/index-B2ja9r7W.js (the notes worker) referring to /assets/index-Cjb8p4yi.js, which is not in dist/. In the built app, the renderer log shows Failed to load module script: … MIME type of "text/plain" (the 404) and Uncaught (in promise) Error: undefined from getNotesList, and the note list never loads. The commit before chore(deps-dev): bump vite from 8.0.16 to 8.3.5 #196 (Vite 8.0.16) emits the file; Vite 8.3.5 does not.
    With the new guard and the old import, the build fails: The build refers to scripts it did not write: assets/index-Cjb8p4yi.js (referenced by assets/index-B4hWaYhT.js).
  • After: the build passes the guard and writes the parser worker. The built app (served over neno://, launched with Playwright's Electron driver against a scratch graph) lists the graph's notes. npm run test (367 tests), npm run lint, npm run build and npm run integration-test (65 tests) pass.

Merge Danger

Door: two-way

One import replaced, one build check added; revert the commit to undo.

Blast Radius: build

The new check fails a build that refers to a missing script, so a future dependency bump that drops an asset fails CI instead of shipping. Only /assets/*.js references in emitted scripts are checked.

🤖 Generated with Claude Code

Since the Vite 8.3 upgrade (#196), a `?worker&url` asset imported from
inside a worker is no longer written out. The notes worker imports the
subwaytext parser that way, so a production build kept a URL to a file
that did not exist: the parser workers failed to start, and every graph
read — the note list first — rejected with `undefined`. The dev server,
and with it the Playwright suite, was unaffected.

Start the parser pool with `new Worker(new URL(…, import.meta.url))`,
the form Vite resolves itself, and fail the build whenever an emitted
script refers to an asset that is missing, so the next upgrade that
drops one is caught at build time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@polyrainbow
polyrainbow merged commit d0e8faf into main Nov 6, 2026
6 checks passed
@polyrainbow
polyrainbow deleted the fix/nested-worker-build branch November 6, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant