Skip to content

Dev server crashes when octane.config.ts imports decorator-using code (virtual module ids reach the file watcher) #988

Closed

Description

@ciokyyy

Dev server crashes when octane.config.ts imports decorator-using code (virtual module ids reach the file watcher)

Summary

vite dies at startup with ERR_INVALID_ARG_VALUE if octane.config.ts transitively imports a module that uses TypeScript decorators. The oxc transform injects a helper as a rollup virtual module, whose id begins with a NUL byte. viteConfigModuleRunner().getDependencies() collects it as a config dependency and configureServer passes it to vite.watcher.add(), which cannot stat it.

Package: @octanejs/[email protected], [email protected], [email protected], Node v26.7.0.

Repro

octane.config.ts imports a server module that uses decorators. In my case Remult entities:

// octane.config.ts
import { defineConfig, ServerRoute } from "@octanejs/vite-plugin";
import { api } from "./src/server/api"; // -> remult @Entity / @Fields decorators

export default defineConfig({
  router: {
    routes: [new ServerRoute({ path: "/api/*", handler: ({ request }) => api.fetch(request) })],
  },
});

Then vite.

Actual

TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string, Uint8Array, or URL without null bytes.
Received '/home/user/project/\x00@[email protected]/helpers/esm/decorate.js'
    at Object.stat (node:fs:1977:10)
    at NodeFsHandler._addToNodeFs (vite/dist/node/chunks/node.js:9780:51)
    at FSWatcher.add (vite/dist/node/chunks/node.js:10446:23)
    at BasicMinimalPluginContext.configureServer (@octanejs/vite-plugin/src/index.js:498:18)
Emitted 'error' event on FSWatcher instance

Cause

In src/load-config.js, the module-graph walk in viteConfigModuleRunner adds every module.file it sees:

if (module.file) dependencies.add(module.file);

Vite populates file for virtual modules too, keeping the \0 prefix. Those ids flow into compilerConfigWatchFiles via path.resolve(file) in index.js, and then into vite.watcher.add([...compilerConfigWatchFiles]).

Suggested fix

Filter virtual ids at the collection point, so both watcher call sites in index.js are covered:

-				if (module.file) dependencies.add(module.file);
+				if (module.file && !module.file.includes('\0')) dependencies.add(module.file);

Verified locally as a patch: dev server boots, and touching octane.config.ts still triggers a server restart.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions