Skip to content

fix(compress): convert strong ETag to weak ETag when compressing#4848

Merged
yusukebe merged 1 commit intomainfrom
fix-compress-etag
Mar 31, 2026
Merged

fix(compress): convert strong ETag to weak ETag when compressing#4848
yusukebe merged 1 commit intomainfrom
fix-compress-etag

Conversation

@usualoma
Copy link
Copy Markdown
Member

fixes #4845

Convert strong ETag to weak ETag (W/ prefix) when the compress middleware compresses the response.

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code

Compressed content is not byte-identical to the original, so strong
ETags violate HTTP semantics (RFC 9110). Convert them to weak ETags
by adding the W/ prefix, matching the behavior of nginx, Apache, and
Express.
@github-actions
Copy link
Copy Markdown

Bundle size check

main (018277e) #4848 (35ae980) +/-
Bundle Size (B) 18,489B 18,489B 0B
Bundle Size (KB) 18.06K 18.06K 0K

Compiler Diagnostics (tsc)

main (018277e) #4848 (35ae980) +/-
Files 229 229 0
Lines 146,731 146,731 0
Identifiers 124,420 124,420 0
Symbols 150,583 150,583 0
Types 157,112 157,112 0
Instantiations 401,446 401,446 0
Memory used 252,815K 251,347K -1,468K
I/O read 0.03s 0.04s 0.01s
I/O write 0s 0s 0s
Parse time 0.72s 0.7s -0.02s
Bind time 0.28s 0.28s 0s
Check time 1.46s 1.44s -0.02s
Emit time 0.01s 0.01s 0s
Total time 2.47s 2.43s -0.04s

Compiler Diagnostics (typescript-go)

main (018277e) #4848 (35ae980) +/-
Files 229 229 0
Lines 150,912 150,912 0
Identifiers 125,098 125,098 0
Symbols 190,886 190,886 0
Types 255,496 255,496 0
Instantiations 608,997 608,997 0
Memory used 162,050K 162,075K 25K
Memory allocs 1,767,620 1,767,772 152
Config time 0.001s 0.001s 0s
BuildInfo read time 0.001s 0.001s 0s
Parse time 0.094s 0.101s 0.007s
Bind time 0s 0s 0s
Check time 0.447s 0.425s -0.022s
Emit time 0.005s 0.008s 0.003s
Changes compute time 0.026s 0.022s -0.004s
Total time 0.611s 0.589s -0.022s

Reported by octocov

@github-actions
Copy link
Copy Markdown

HTTP Performance Benchmark

Framework Runtime Average Ping Query Body
hono (origin/main) bun 35,478.73 49,726.74 31,694.41 25,015.05
hono (current) bun 35,519.17 49,887.21 31,961.05 24,709.25
Change +0.11% +0.32% +0.84% -1.22%

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.84%. Comparing base (018277e) to head (5f30eab).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4848   +/-   ##
=======================================
  Coverage   92.84%   92.84%           
=======================================
  Files         177      177           
  Lines       11643    11647    +4     
  Branches     3468     3469    +1     
=======================================
+ Hits        10810    10814    +4     
  Misses        832      832           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 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.

@usualoma
Copy link
Copy Markdown
Member Author

@sebastian-nowak's suggestion makes sense, and I think we should address it.

@usualoma
Copy link
Copy Markdown
Member Author

Hi @yusukebe,
Would you mind reviewing this?

Copy link
Copy Markdown
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Copy Markdown
Member

@usualoma

I see! The issue should be fixed. Thanks.

@yusukebe yusukebe merged commit 0bce36b into main Mar 31, 2026
20 checks passed
@yusukebe yusukebe deleted the fix-compress-etag branch March 31, 2026 08:17
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.

compress() middleware should change etags to weak

2 participants