cloudflare / cloudflare/workers-sdk

🐛 BUG: pages dev server throws 500 errors while serving many requests in parallel

Open
#5,552 0 comments 1 reaction 3 assignees Claimed by @stritt View on GitHub
package:wrangler product:pages
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
187

Description

### Which Cloudflare product(s) does this pertain to?

Pages, Wrangler core, Miniflare

### What version(s) of the tool(s) are you using?

3.48.0

### What version of Node are you using?

v20.12.1

### What operating system and version are you using?

Tested on Windows, macOS, and Linux

### Describe the Bug

### Observed behavior

While under sustained load (due to multiple simultaneous connections from headless playwright integration test browsers), `wrangler pages dev` will occasionally return 500 errors instead of serving assets.

Some important notes:
- I have reproduced this issue on macOS, Linux, and Windows.
- This issue occurs _both_ with the `--proxy` or `-- ` invocation AND when serving an application via `wrangler pages dev `.
- There issue appears to impact all static assets equally -- in our testing, it appears equally likely for a GET request for a JavaScript. image, or font asset to return a `500 Internal Server Error `.

### Expected behavior

`wrangler pages dev` does not return 500 errors when serving static assets.

### Steps to reproduce

Run `npx wrangler pages dev` while serving a static directory, and then make many simultaneous requests to it. In our testing, we get 500 errors once every 100 requests or so when running 18 concurrent playwright browsers (this is on a powerful machine with 24 cores). The errors appear intermittently -- hundreds of requests will be fine, then a couple will randomly 500. As concurrency decreases, the chances of getting a 500 error decreases as well.

Here is my npx invocation:

`npx wrangler pages dev --do ROOM_DURABLE_OBJECT=RoomDurableObject@gg-local-gameserver --compatibility-date=2023-09-22 --port=8173 --proxy=6333`

### Please provide a link to a minimal reproduction

_No response_

### Please provide any relevant error logs

The stacktrace below is for windows, but I want to emphasize that this issue is reliably reproducible on Windows, macOS, and Linux. Below is a Windows stacktrace.

```
[wrangler:inf] GET /src/components/Scope.tsx 500 Internal Server Error (462ms)
[wrangler:err] Error: internal error
at async next (file:///C:/Users/Avi/Documents/GitHub/magiccircle.gg/node_modules/.pnpm/wrangler@3.48.0/node_modules/wrangler/templates/pages-template-worker.ts:170:22)
at async Object.fetch (file:///C:/Users/Avi/Documents/GitHub/magiccircle.gg/node_modules/.pnpm/wrangler@3.48.0/node_modules/wrangler/templates/pages-template-worker.ts:180:11)
at async jsonError (file:///C:/Users/Avi/Documents/GitHub/magiccircle.gg/node_modules/.pnpm/wrangler@3.48.0/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:10)
at async drainBody (file:///C:/Users/Avi/Documents/GitHub/magiccircle.gg/node_modules/.pnpm/wrangler@3.48.0/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts:5:10)
at async jsonError (file:///C:/Users/Avi/Documents/GitHub/magiccircle.gg/node_modules/.pnpm/wrangler@3.48.0/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:10)
at async drainBody (file:///C:/Users/Avi/Documents/GitHub/magiccircle.gg/node_modules/.pnpm/wrangler@3.48.0/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts:5:10)
at async jsonError2 (file:///C:/Users/Avi/Documents/GitHub/magiccircle.gg/node_modules/.pnpm/wrangler@3.48.0/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:10)
at async drainBody2 (file:///C:/Users/Avi/Documents/GitHub/magiccircle.gg/node_modules/.pnpm/wrangler@3.48.0/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts:5:10)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.