Skip to content

Unstable_DevWorker.fetch fails when request has a body and receives a 401 response #12967

@beanow-at-crabnebula

Description

@beanow-at-crabnebula

What versions & operating system are you using?

Problem seems introduced in #12927

On Linux (x86_64)

  "devDependencies": {
    "@types/jest": "^29.5.11",
    "@types/node": "^25.5.0",
    "jest": "^29.7.0",
    "ts-jest": "^29.4.6",
    "typescript": "^5.3.3",
    "undici": "^7.24.4",
    "wrangler": "^4.75.0"
  },
  "dependencies": {
    "hono": "^4.12.2"
  }

Please provide a link to a minimal reproduction

https://github.com/beanow-at-crabnebula/undici-401-request-body

Describe the Bug

This seemed like a potential regression in undici and I've reported upstream: nodejs/undici#4910
However with purely undici and nodejs it wasn't easily reproducible.

What seems to be from a change in nodejs/undici#4747

Any (non websocket) request that includes a request body and gets a 401 response errors.

    TypeError: fetch failed

      at Object.processResponse (node_modules/.pnpm/wrangler@4.75.0/node_modules/wrangler/wrangler-dist/cli.js:31323:21)
      at node_modules/.pnpm/wrangler@4.75.0/node_modules/wrangler/wrangler-dist/cli.js:31709:23

    Cause:
    expected non-null body source

      at makeNetworkError (node_modules/.pnpm/wrangler@4.75.0/node_modules/wrangler/wrangler-dist/cli.js:30097:36)
      at httpNetworkOrCacheFetch (node_modules/.pnpm/wrangler@4.75.0/node_modules/wrangler/wrangler-dist/cli.js:31924:20)
      at httpFetch (node_modules/.pnpm/wrangler@4.75.0/node_modules/wrangler/wrangler-dist/cli.js:31733:37)
      at mainFetch (node_modules/.pnpm/wrangler@4.75.0/node_modules/wrangler/wrangler-dist/cli.js:31495:24)

Please provide any relevant error logs

No response

Metadata

Metadata

Labels

wranglerRelating to the Wrangler CLI tool

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions