Workers SDK Issue Reports

← Back to Dashboard

#8917 `wrangler dev` throws internal error for HEAD requests

Recommendation:KEEP OPEN
Difficulty:easy
Reasoning:

Confirmed bug: `handlePrettyErrorRequest` calls `request.json()` on HEAD requests which have no body. Cloudflare member verified still broken in 4.53.0.

Suggested Action:

Keep open for miniflare fix

Analysis Report

Issue Review: cloudflare/workers-sdk#8917

Summary

wrangler dev throws a confusing JSON parse error instead of showing worker errors when debugging with HEAD requests (e.g., curl -I).

Findings

  • Created: 2025-04-12
  • Updated: 2025-12-08
  • Version: 4.10.0 → 4.60.0 (current)
  • Component: miniflare (error handling)
  • Labels: bug
  • Comments: 1 (member confirmed still broken in 4.53.0)

Key Evidence

  • Bug confirmed still present in wrangler 4.53.0 by @Lekensteyn (Cloudflare member) on 2025-12-08
  • Root cause identified: packages/miniflare/src/plugins/core/errors/index.ts:280 calls await request.json() without checking if request has a body
  • HEAD requests by HTTP spec have no body, so JSON.parse fails with "Unexpected end of JSON input"
  • No PRs found that reference this issue or fix this specific problem
  • Issue not mentioned in any changelogs
  • Code inspection confirms the bug still exists in the current codebase

Root Cause

The handlePrettyErrorRequest function in miniflare assumes the error request has a JSON body, but HEAD requests have empty bodies per HTTP specification. The fix would require checking the request method or body presence before attempting to parse JSON.

Recommendation

Status: KEEP OPEN

Reasoning: This is a confirmed, reproducible bug that affects developer experience when debugging workers using HEAD requests. A Cloudflare team member confirmed it's still present in recent versions, and code inspection confirms no fix has been applied. The bug has a clear root cause and straightforward fix.

Action: Keep open. The bug is valid and needs a fix in packages/miniflare/src/plugins/core/errors/index.ts to handle HEAD requests gracefully.

Notes & Feedback (0)

No notes yet.

Add Note