Description
Describe the bug
The caching of concurrentModuleNodePromises
implemented in the ModuleRunner
is not compatible with the Cloudflare Workers runtime.
vite/packages/vite/src/module-runner/runner.ts
Lines 233 to 251 in ec06767
This is because it violates a constraint of the Workers runtime that I/O objects can't be shared between invocations (https://developers.cloudflare.com/workers/observability/errors/#cannot-perform-io-on-behalf-of-a-different-request). We have only encountered this recently when debugging cloudflare/workers-sdk#9518 but it seems to be a common issue for users building larger apps.
It would be good to understand if this promise caching is just an optimisation or if it serves to prevent invalid states. If it's just an optimisation then the simplest option might be to offer a way to opt out.
Reproduction
https://github.com/SlexAxton/cf-bug-repro-9518
Steps to reproduce
cloudflare/workers-sdk#9518 (comment)
System Info
System:
OS: macOS 15.5
CPU: (12) arm64 Apple M3 Pro
Memory: 4.12 GB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.2.0 - ~/.nvm/versions/node/v24.2.0/bin/node
npm: 11.3.0 - ~/.nvm/versions/node/v24.2.0/bin/npm
pnpm: 10.12.1 - ~/.nvm/versions/node/v24.2.0/bin/pnpm
Browsers:
Chrome: 137.0.7151.120
Safari: 18.5
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.