Skip to content

fix(context): allow c.header() after the response body is consumed - #5587

Merged
yusukebe merged 1 commit into
mainfrom
fix/header-after-body-consumed
Oct 30, 2026
Merged

yusukebe merged 1 commit into
mainfrom
fix/header-after-body-consumed

Conversation

@yusukebe

@yusukebe yusukebe commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Fixes #5586.

Since #4078, c.header() recreates the finalized Response to get mutable headers. A consumed body can't be passed to new Response(), so in that case skip the recreation and set the header on the existing Response, as before #4078.

The author should do the following, if applicable

  • Add tests
  • Run tests
  • pnpm run check:fix to format and lint the code
  • Add TSDoc/JSDoc to document the code

@github-actions

Copy link
Copy Markdown

Bundle size check

main (bac5c4a) #5587 (dc002e6) +/-
Bundle Size (B) 18,443B 18,462B +19B
Bundle Size (KB) 18.01K 18.03K +0.02K

Compiler Diagnostics (tsc)

main (bac5c4a) #5587 (dc002e6) +/-
Files 83 83 0
Lines 59,458 59,458 0
Identifiers 60,635 60,635 0
Symbols 106,536 106,536 0
Types 163,092 163,092 0
Instantiations 414,023 414,023 0
Memory used 208,270K 205,574K -2,696K
I/O read 0.01s 0.01s 0s
I/O write 0s 0s 0s
Parse time 0.25s 0.37s +0.12s
Bind time 0.09s 0.12s +0.03s
Check time 0.97s 1.36s +0.39s
Emit time 0s 0s 0s
Total time 1.3s 1.86s +0.56s

Compiler Diagnostics (typescript-go)

main (bac5c4a) #5587 (dc002e6) +/-
Files 215 215 0
Lines 121,020 121,020 0
Identifiers 107,363 107,363 0
Symbols 181,168 181,168 0
Types 262,348 262,348 0
Instantiations 621,588 621,588 0
Memory used 154,076K 154,068K -8K
Memory allocs 1,783,727 1,784,067 +340
Config time 0s 0.001s +0.001s
BuildInfo read time 0s 0s 0s
Parse time 0.073s 0.098s +0.025s
Bind time 0s 0s 0s
Check time 0.347s 0.461s +0.114s
Emit time 0.008s 0.004s -0.004s
Changes compute time 0.031s 0.034s +0.003s
Total time 0.484s 0.635s +0.151s

Reported by octocov

@github-actions

Copy link
Copy Markdown

HTTP Performance Benchmark

Framework Runtime Average Ping Query Body
hono (origin/main) bun 38,215.87 52,220.69 34,318.92 28,108.01
hono (current) bun 38,352.52 52,781.81 34,582.06 27,693.68
Change +0.36% +1.07% +0.77% -1.47%

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.31%. Comparing base (bac5c4a) to head (35ce6a0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5587   +/-   ##
=======================================
  Coverage   80.31%   80.31%           
=======================================
  Files         149      149           
  Lines       10529    10529           
  Branches     2358     2358           
=======================================
  Hits         8456     8456           
  Misses       2073     2073           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yusukebe
yusukebe merged commit 17ad0e2 into main Oct 30, 2026
32 of 33 checks passed
@yusukebe
yusukebe deleted the fix/header-after-body-consumed branch October 30, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

c.header() crashes after consumption of the finalized res body

1 participant