Skip to content

v8_middleware does not work with Cloudflare Workers #14496

@singingwolfboy

Description

@singingwolfboy

Reproduction

https://github.com/singingwolfboy/test-cf-rr-middleware

System Info

System:
    OS: macOS 26.0.1
    CPU: (8) arm64 Apple M1
    Memory: 105.34 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 25.1.0 - /opt/homebrew/bin/node
    npm: 11.6.2 - /opt/homebrew/bin/npm
    pnpm: 10.20.0 - /opt/homebrew/bin/pnpm
    bun: 1.3.1 - /opt/homebrew/bin/bun
  Browsers:
    Firefox: 142.0.1
    Safari: 26.0.1
  npmPackages:
    @react-router/dev: ^7.9.5 => 7.9.5 
    @react-router/node: ^7.9.5 => 7.9.5 
    react-router: ^7.9.5 => 7.9.5 
    vite: ^7.1.12 => 7.1.12

Used Package Manager

npm

Expected Behavior

I expect that the v8_middleware feature should work as documented, both on local development and on production, using Cloudflare Workers.

Actual Behavior

Trying to launch the dev server produces an error, as documented in the reproduction repo:

[vite] Internal server error: Failed to load url node:stream (resolved id: node:stream) in /Users/singingwolfboy/clones/test-cf-rr-middleware/node_modules/@react-router/dev/dist/config/defaults/entry.server.node.tsx. Does the file exist?
      at CustomModuleRunner.cachedModule (workers/runner-worker.js:1302:20)
      at request (workers/runner-worker.js:1152:83)
      at null.<anonymous> (/Users/singingwolfboy/clones/test-cf-rr-middleware/node_modules/@react-router/dev/dist/config/defaults/entry.server.node.tsx:1:1)
      at Object.runInlinedModule (workers/runner-worker.js:1403:4)
      at CustomModuleRunner.directRequest (workers/runner-worker.js:1206:59)
      at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1113:73)
      at null.<anonymous> (/server-build/virtual:react-router/server-build:2:5)
      at Object.runInlinedModule (workers/runner-worker.js:1403:4)
      at CustomModuleRunner.directRequest (workers/runner-worker.js:1206:59)
      at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1113:73)
[vite] Unexpected Node.js imports for environment "ssr". Do you need to enable the "nodejs_compat" compatibility flag? Refer to https://developers.cloudflare.com/workers/runtime-apis/nodejs/ for more details.
 - "node:stream" imported from "node_modules/@react-router/dev/dist/config/defaults/entry.server.node.tsx"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions