cloudflare / cloudflare/workers-sdk

vite-plugin: `vite dev` does not throw an error when async i/o runs outside a request context

Open
#9,489 2 comments 4 reactions 0 assignees View on GitHub
package:vite-plugin
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.