Skip to content

wrangler dev throws an internal error when reporting a worker error for a HEAD request #8917

@jyn514

Description

@jyn514

Which Cloudflare product(s) does this pertain to?

Wrangler

What versions & operating system are you using?

wrangler 4.10.0

Please provide a link to a minimal reproduction

https://github.com/jyn514/redirect-worker/tree/super-broken

Describe the Bug

my worker has an internal error, which i want to see the message for. i ran curl -I to make it show up in the logs. instead of seeing my worker's error, i see a syntax error in wrangler internals:

[wrangler:err] SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (/home/jyn/Documents/node-v20.12.2-linux-x64/lib/node_modules/wrangler/node_modules/undici/lib/fetch/body.js:590:15)
    at successSteps (/home/jyn/Documents/node-v20.12.2-linux-x64/lib/node_modules/wrangler/node_modules/undici/lib/fetch/body.js:530:23)
    at fullyReadBody (/home/jyn/Documents/node-v20.12.2-linux-x64/lib/node_modules/wrangler/node_modules/undici/lib/fetch/util.js:959:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async specConsumeBody (/home/jyn/Documents/node-v20.12.2-linux-x64/lib/node_modules/wrangler/node_modules/undici/lib/fetch/body.js:545:3)
    at async handlePrettyErrorRequest (/home/jyn/Documents/node-v20.12.2-linux-x64/lib/node_modules/wrangler/node_modules/miniflare/dist/src/index.js:11164:40)
    at async #handleLoopback (/home/jyn/Documents/node-v20.12.2-linux-x64/lib/node_modules/wrangler/node_modules/miniflare/dist/src/index.js:15458:20)
[wrangler:inf] HEAD / 500 Internal Server Error (3ms)

if i do a GET instead of a HEAD, i see the expected worker error:

[wrangler:err] ReferenceError: Url is not defined
    at Object.fetch (file:///home/jyn/src/redirect-worker/src/worker.js:32:18)
    at fetchDispatcher (file:///home/jyn/src/redirect-worker/.wrangler/tmp/bundle-HPW4lZ/middleware-loader.entry.ts:54:17)
[wrangler:inf] GET / 500 Internal Server Error (9ms)

steps to replicate:

  1. clone the repo in the issue description
  2. wrangler dev
  3. curl -I localhost:8787

Please provide any relevant error logs

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions