Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Response body object should not be disturbed or locked" error with Node.js middleware and large request bodies | GoodFirstPicks

Response body object should not be disturbed or locked" error with Node.js middleware and large request bodies

vercel/next.js 13 comments 14d ago
View on GitHub
highopenScope: somewhat clearSkill match: maybeTest focusedNext.jsTypeScriptReact

Why this is a good first issue

Intermittent failure with large request bodies in middleware requires deep understanding of Next.js internals.

AI Summary

The issue involves intermittent failures when processing large request bodies (>350MB) in Next.js middleware, leading to a fatal error. The problem appears to be related to Node.js runtime and Next.js internals, with a hardware-dependent threshold. A fix would require deep understanding of both Next.js and Node.js request handling mechanisms.

Issue Description

Link to the code that reproduces this issue

https://github.com/platformshape/nextjs-body-bug-repro

To Reproduce

  1. npm install && npm run dev
  2. chmod +x test.sh && ./test.sh 500 && ./test.sh 500

The issue is intermittent and never fails on the first request after launching the server. It does however fail after a few tries.

Current vs. Expected behavior

Next.js v15.5.2 throws a fatal error when using Node.js runtime middleware with large request bodies (>350MB):

TypeError: Response body object should not be disturbed or locked
    at extractBody (node:internal/deps/undici/undici:5574:17)
    at new Request (node:internal/deps/undici/undici:9801:48)
    at new NextRequest (/path/to/next/server/chunks/node_modules_next_dist_*.js)

This results in a 500 Internal Server Error and prevents processing of large file uploads through middleware.

Expected: Large file uploads processed successfully through middleware to API route.

Actual:

  • ✅ Files ≤350MB: Work correctly
  • ❌ Files >350MB: Fatal error with 500 status

Test Results

File SizeStatusNotes
100MB✅ WorksNo issues
300MB✅ WorksNo issues
350MB✅ WorksThreshold
375MB❌ FailsConsistent failure
400MB+❌ FailsAlways fails

Error Details

Console Error:

TypeError: Response body object should not be disturbed or locked
    at extractBody (node:internal/deps/undici/undici:5574:17)
    at new Request (node:internal/deps/undici/undici:9801:48)
    at new NextRequest (/private/tmp/my-app/.next/server/chunks/node_modules_next_dist_eb0c80da._.js:5368:14)
    at NextRequestAdapter.fromNodeNextRequest (/private/tmp/my-app/.next/server/chunks/node_modules_next_dist_eb0c80da._.js:5539:16)
    at handler (/private/tmp/my-app/.next/server/chunks/node_modules_next_dist_eb0c80da._.js:8127:246)

Server Logs:

Middleware: POST http://localhost:3000/api/upload

GitHub Labels

Middlewarelinear: next

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 35 points when you complete it!

Risk Flags

  • intermittent failure
  • hardware-dependent threshold
  • large request bodies
Loading labels...

Details

Points35 pts
Difficultyhigh
Scopesomewhat clear
Skill Matchmaybe
Test Focusedyes