Skip to content

Native Void worker: dep scan can't follow the generated entry, so routes and Durable Objects deps reload the dev worker and can crash it #914

Backlog

Description

@SweetRetry

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

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 dev

It 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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions