cloudflare / cloudflare/workerd
🐛 Bug Report — Runtime APIs -- PromiseFulfiller destroyed without fulfilling promise in Vitest tests on Windows 11
- Dominant language
- C++
- Stars
- 8.7k
- Forks
- 739
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 174
Description
## What is the problem?
When running Vitest tests on **Windows 11**, tests that make HTTP requests to the worker fail with a `PromiseFulfiller was destroyed without fulfilling the promise` error. The same tests work perfectly on **macOS**.
**Working scenarios:**
- Worker runs correctly with `npx wrangler dev` on both platforms
- Worker deployment and runtime work correctly on both platforms
- Vitest tests work correctly on macOS
**Failing scenario:**
- Vitest tests fail on Windows 11 with the error below
## What are the error messages?
```
workerd/jsg/util.c++:320: error: e = kj/async.c++:3136: failed: PromiseFulfiller was destroyed without fulfilling the promise.
stack: 7ff7969fd065 7ff79659eedd 7ff796c9557f 7ff7969fd866 7ff7969f7d62 7ff79659fd8b 7ff7969f833b 7ff796a24573 7ff7969f7e3c 7ff7969feb3f 7ff796a00c51 7ff7969f6397 7ff79539396b 7ff796a4a4ff 7ff796a516a6 7ff796a4aa03 7ff79538b500 0 0 0 0 0; sentryErrorContext = jsgInternalError; wdErrId = 6gissi69k74mnt6i9b5um3ud
```
## What is the expected behavior?
Tests should run successfully on both macOS and Windows 11, similar to how the worker works correctly with `npx wrangler dev` on both platforms.
## What is the actual behavior?
Tests fail on Windows 11 with the promise lifecycle error, while working correctly on macOS.
## Code sample
### vitest.config.ts
```typescript
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
export default defineWorkersConfig({
test: {
poolOptions: {
workers: {
isolatedStorage: false,
wrangler: { configPath: "./wrangler.jsonc" },
miniflare: {
"env": {
"dev" : {
"workflows": [
{
"name": "workflows",
"binding": "MY_WORKFLOW",
"class_name": "MyWorkflow"
}
]
}
},
}
},
},
},
});
```
### wrangler.jsonc
```json
{
"name": "test-worker",
"main": "src/routes/api.ts",
"compatibility_date": "2025-03-17",
"compatibility_flags": [
"nodejs_compat",
"nodejs_compat_populate_process_env"
],
"vars": {
"ENVIRONMENT": "local"
},
"env": {
"dev" : {
"vars": {
"ENVIRONMENT": "dev"
},
"workflows": [
{
"name": "workflows",
"binding": "MY_WORKFLOW",
"class_name": "MyWorkflow"
}
]
},
"prod" : {
"vars": {
"ENVIRONMENT": "prod",
},
"workflows": [
{
"name": "workflows",
"binding": "MY_WORKFLOW",
"class_name": "MyWorkflow"
}
]
}
},
"assets": {
"directory": "public"
},
"durable_objects": {
"bindings": [
{
"name": "WorkerAgent",
"class_name": "WorkerAgent"
},
{
"name": "Manager",
"class_name": "Manager"
},
{
"name": "ChatAgent",
"class_name": "ChatAgent"
}
]
},
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": [
"WorkerAgent", "Manager", "ChatAgent",
]
}
],
"workflows": [
{
"name": "workflows",
"binding": "MY_WORKFLOW",
"class_name": "MyWorkflow"
}
],
"observability": {
"enabled": true
}
}
```
### Test that fails
```typescript
it("should handle API request successfully", async () => {
const payload = {
amount: 100,
reason: "Test data"
};
const request = new Request("http://127.0.0.1:8787/api/endpoint", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Basic [redacted]"
},
body: JSON.stringify(payload),
});
const ctx = createExecutionContext();
try {
const response = await app.fetch(request, env, ctx);
await waitOnExecutionContext(ctx);
expect(response.status).toBe(200);
// Additional assertions...
} catch (error) {
console.error("Test error:", error);
throw error;
}
});
```
## What version of workerd are you using?
From package.json:
- `@cloudflare/vitest-pool-workers`: ^0.8.5
- `vitest`: ^3.0.9
- `wrangler`: ^4.23.0
- `@cloudflare/vite-plugin`: 0.1.16
- `vite`: ^6.2.3
## What operating system are you using?
- **macOS**: Tests work correctly
- **Windows 11**: Tests fail
## Additional context
- The issue appears to be platform-specific (Windows 11 vs macOS)
- The error suggests a promise lifecycle issue within the workerd runtime
- All external API calls work correctly outside of the Vitest environment
This appears to be a platform-specific issue in workerd's promise handling, potentially related to how the Windows version manages promise lifecycles during test execution compared to the macOS version.
Contributor guide
Assessment
This issue has not been assessed yet.