[cloudflare_module]: Attempting to call readRawBody in a Nitro route for a DELETE request throws a 500 error and terminates the request
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Environment
------------------------------
- Operating System: Darwin
- Node Version: v22.14.0
- Nuxt Version: 4.1.3
- CLI Version: 3.29.3
- Nitro Version: 2.12.6
- Package Manager: pnpm@10.18.3
- Builder: -
- User Config: -
- Runtime Modules: -
- Build Modules: -
------------------------------
Reproduction
Reproduction requires deploying into the actual Cloudflare Worker environment. Running wrangler locally does not surface the issue.
We deploy with the cloudflare-worker Nitro preset.
main = "./.output/server/index.mjs"
assets = { directory = "./.output/public/", binding = "ASSETS" }
name = "my-worker"
workers_dev = false
preview_urls = true
compatibility_date = "2025-09-15"
compatibility_flags = [
"nodejs_compat",
"no_nodejs_compat_v2", # https://github.com/unjs/unenv/issues/364#issuecomment-2575237049
]
rules = [
{ type = "ESModule", globs = ["**/*.js", "**/*.mjs"]},
]
minify = true
logpush = true
send_metrics = true
upload_source_maps = true
find_additional_modules = true # See https://github.com/unjs/unenv/issues/364#issuecomment-2734680242
[observability]
enabled = true
// foo.delete.ts
// ...more code
// Calling `readRawBody` here immediately throws a 500 error and terminates the request on Cloudflare
const body = ['PATCH', 'POST', 'PUT', 'DELETE'].includes(event.method) ? await readRawBody(event, 'utf-8') : undefined
// ...more code
return sendProxy(event, ...)
Describe the bug
Attempting to call readRawBody in a Nitro route for a DELETE request throws a 500 error and terminates the request
Additional context
Even if you explicitly send body: undefined to the endpoint, calling await readRawBody(event, 'utf-8') in the Nitro endpoint appears to throw the error.
Logs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the foo.delete.ts reproduction and the readRawBody call under the cloudflare-worker Nitro preset. Deploy it to an actual Cloudflare Worker, since local wrangler does not reproduce the failure, and inspect the request handling for DELETE bodies. Done means readRawBody no longer produces a 500 error or terminates the request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100