When a dev environment transforms a module that imports a bare specifier
between createServer() and server.listen(), the deps optimizer can
crash while committing the pre-bundle:
[vite] (ssr) error while updating dependencies:
TypeError: Cannot read properties of undefined (reading 'browserHash')
at commitProcessing (…/vite/dist/node/chunks/node.js:33347:134)
at async runOptimizer (…/vite/dist/node/chunks/node.js:33364:5)
Transforming before listen() is what framework integrations do when they
eagerly load a module during setup, so in real projects this surfaces as an
intermittent, timing-dependent error at dev-server startup.
npm installThe repro runs automatically via postinstall; re-run it any time with
node repro.mjs.
repro.mjs:
- creates a Vite server with an
ssrenvironment that has dep optimization enabled (optimizeDeps.noDiscovery: false,resolve.noExternal: true), - calls
transformRequest("/entry.js")(which importslodash-es) beforelisten(), - waits 120ms (the optimizer discovers the dep and starts pre-bundling on a 100ms debounce),
- calls
server.listen()while that pre-bundle is in flight.
The dep is pre-bundled without errors (or, at worst, is re-discovered after startup).
[vite] (ssr) error while updating dependencies:
TypeError: Cannot read properties of undefined (reading 'browserHash')
at commitProcessing (…)
at async runOptimizer (…)
Reproduces deterministically with this repro. In real projects the same error
appears intermittently at dev startup — it depends on the pre-bundle still
being in flight when listen() runs, so it is more likely with cold OS file
caches (first run of the day, right after installing dependencies).
- vite 8.1.3
- Node v26.3.1
- macOS 15.7.7 (also observed on Linux)