Skip to content

Failed to find Response internal state key" Warning in Node.js v24.3.0 due to undici changes #254

@Dantescur

Description

@Dantescur

Describe the bug
When using @hono/[email protected] with Node.js v24.3.0, a warning is logged: "Failed to find Response internal state key." This occurs in getInternalBody because it attempts to access Symbol(state) on Response objects, which is not exposed by undici in Node.js v24.3.0 (it uses a private #state field instead). Despite the warning, responses are still served correctly, but the log noise could indicate deeper compatibility issues. After some digging seems is caused by this PR

To Reproduce

  1. Set up a Hono server with @hono/[email protected] and Node.js v24.3.0. (with pnpm create hono@latest)
  2. Run the server (pnpm dev with tsx watch src/index.ts).
  3. Observe the warning in the console:
    Failed to find Response internal state key

Expected behavior
No warnings should be logged.

Proposed Fix

The issue is caused by getInternalBody relying on

Reflect.ownKeys(new GlobalResponse()).find((k) => typeof k === "symbol" && k.toString() === "Symbol(state)")

to access the internal state of Response objects. Since undici in Node.js v24.3.0 uses a private #state field, this approach fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions