AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Bug: `Expected Non-Null Body Source` When Passing A `Request` Object To Fetch AND Receiving An Error Response (Node >= 24.14.0)

Next.js patched fetch crashes with TypeError when a Request object containing a JSON body is passed directly and the server responds with an error status, on Node.js >=24.14.0 due to undici strict stream locking.

highConfidence 91%Next.jsReact Server ComponentsServer ActionsAffected V16.1.6

Origin Analysis

Next.js internal patch-fetch logic attempts to read or clone the original Request body for error logging, tracing, or cache evaluation after it has already been consumed by the outbound network request. On Node.js 24.14.0+, undici enforces strict stream locking, causing 'expected non-null body source' when accessing an already-locked or consumed body stream.
1. Create a Next.js App Router handler (Server Action or Route Handler). 2. In the handler, create a Request object with method POST, JSON stringified body, and header Content-Type: application/json. 3. Pass the Request object directly to global fetch against an endpoint returning a 4xx/5xx status (e.g., https://httpstat.us/401). 4. Observe the crash: TypeError: expected non-null body source at ignore-listed frames.

Fixing Code Block

Edge Case Audit

This workaround does not preserve all Request properties (e.g., signal, redirect, cache mode, duplex) and may alter behavior. It also consumes a clone of the Request body, so the original Request object remains usable but the function ignores any init argument when input is a Request. It is a temporary mitigation; the official fix should be applied in Next.js patch-fetch. To roll back, remove the wrapper and either pass URL+init directly or import native undici fetch for non-GET requests. For production, prefer upgrading to a Next.js version that resolves the issue.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state