Repository navigation
Description
Summary
In a native Void app, the worker environment's dependency scan finds nothing. The only scan entry is the generated .void/entry.ts. That entry imports durable-objects/* modules by absolute path and routes through virtual:void-routes. Vite's scanner treats an import whose resolved id equals its specifier as external, and it skips \0 virtual ids, so the scan stops at the entry.
Every third-party dependency of routes and Durable Objects is then discovered while the worker starts. Each wave re-optimizes and reloads the worker. When a later wave re-bundles a dependency that already ran (here @tiptap/y-tiptap shares yjs), the reload re-evaluates modules against state from the previous run, and vp dev exits:
vite:deps Scan completed in 30.31ms: no dependencies found
vite:deps new dependencies found: yjs
vite:deps new dependencies found: @tiptap/core, @tiptap/extension-table, @tiptap/y-tiptap, @tiptap/starter-kit
(void_worker) optimized dependencies changed. reloading
Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438
[vite] An error happened during full reload
RangeError: Duplicate use of selection JSON ID cell
error when starting dev server:
RangeError: Duplicate use of selection JSON ID cell
It only happens on a cold dep cache, so it comes back after a lockfile or config change. Apps without such a shared dependency still pay one worker reload per discovery wave.
Cause
createServerRuntimeOptimizerPluginsets workeroptimizeDeps.entriesonly for a frameworkssrEntry(plugin-worker-environment.ts#L200-L245). Its comment already names the problem: the Worker reaches code "through generated modules, which the dependency scan cannot follow".@void/reactPages addspages/**to the worker entries for the same reason (plugin-pages.ts#L84-L100, @void/react: client environment has no optimizeDeps.entries for pages, causing a dev re-optimization reload on first load #599 / fix(react): pre-scan client page deps in Pages dev #620).- Native apps get neither. The generated entry imports Durable Objects by absolute path (router/compile.ts#L1287) and routes through
virtual:void-routes, both invisible to the scan.
Reproduction
Only voidPlugin(), one Durable Object and one local module. Same result on Vite+ 1.4.0 and 1.8.0 (@voidzero-dev/vite-plus-core 8.3.8001).
{
"type": "module",
"dependencies": {
"@tiptap/core": "^3.32.2",
"@tiptap/extension-table": "^3.32.2",
"@tiptap/pm": "^3.32.2",
"@tiptap/starter-kit": "^3.32.2",
"@tiptap/y-tiptap": "^3.0.10",
"yjs": "^13.6.33"
},
"devDependencies": {
"void": "1.11.0",
"vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
"vite-plus": "1.8.0"
}
}// vite.config.ts
import { defineConfig } from 'vite';
import { voidPlugin } from 'void';
export default defineConfig({ plugins: [voidPlugin()] });// void.config.ts
import { defineConfig } from 'void/config';
export default defineConfig({
worker: { compatibility_date: '2026-10-01', compatibility_flags: ['nodejs_compat'] },
});// src/schema.ts
import { getSchema } from '@tiptap/core';
import { TableKit } from '@tiptap/extension-table';
import StarterKit from '@tiptap/starter-kit';
import { prosemirrorJSONToYXmlFragment } from '@tiptap/y-tiptap';
export const schema = getSchema([StarterKit, TableKit]);
export const toY = prosemirrorJSONToYXmlFragment;// durable-objects/counter.ts
import { defineDurableState } from 'void/durable';
import * as Y from 'yjs';
import { schema } from '../src/schema.ts';
const Counter = defineDurableState({
initialState: { count: 0 },
methods: {
increment(context, amount: number) {
context.state.count += amount + (new Y.Doc().clientID > 0 ? 0 : 1);
return schema.nodes.table ? context.state.count : -1;
},
},
});
export default Counter;rm -rf node_modules/.vite && DEBUG=vite:deps vp devIt crashed on every cold start I ran (3 of 3 across the two Vite+ versions).
Workaround
export default defineConfig({
environments: {
void_worker: {
optimizeDeps: { entries: ['durable-objects/**/*.ts', 'routes/**/*.ts'] },
},
},
plugins: [voidPlugin()],
});With it the scan finds all five dependencies up front, the worker starts with no reload, and the crash is gone (3 of 3 cold starts).
Suggested fix
In void:server-runtime-optimizer, give Void's own worker the source files its generated entry reaches as optimizeDeps.entries: routes, Durable Objects, and the other conventions the entry imports (crons, queues, env.ts). Either the convention globs, as @void/react does for pages/**, or the exact file list the router scan already has.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity