cloudflare / cloudflare/workers-sdk
vite-plugin: `vite dev` does not throw an error when async i/o runs outside a request context
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.5k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 187
Description
### What versions & operating system are you using?
`wrangler@4.19.1`, `@cloudflare/vite-plugin:1.5.0`
### Please provide a link to a minimal reproduction
https://github.com/threepointone/test-vite-wrangler-async-io
### Describe the Bug
workerd should throw an error when async i/o is run outside of a request context. for example, this script should throw:
```js
setTimeout(() => {
console.log("timer fired");
}, 1000);
export default {
async fetch(request, env, ctx) {
return new Response("Hello World");
},
};
```
when run with `wrangler dev`, this throws as expected. but it does NOT throw when run with `vite dev`.
### Please provide any relevant error logs
_No response_
Contributor guide
Research direction
Begin with the linked minimal reproduction and compare its behavior under `vite dev` and `wrangler dev`; then trace the `@cloudflare/vite-plugin` entry point used by `vite dev`. Done when the timer example raises the same async-I/O-outside-request-context error under `vite dev` as it does under `wrangler dev`, with regression coverage if the relevant test location is found.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript, vite
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100