Skip to content

[WIP] feat: introduce Route Check Middleware#4703

Draft
yusukebe wants to merge 3 commits intomainfrom
feat/route-check-middleware
Draft

[WIP] feat: introduce Route Check Middleware#4703
yusukebe wants to merge 3 commits intomainfrom
feat/route-check-middleware

Conversation

@yusukebe
Copy link
Member

Resolve #4701

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link

Bundle size check

main (69ad885) #4703 (15fa50c) +/-
Bundle Size (B) 18,438B 18,438B 0B
Bundle Size (KB) 18.01K 18.01K 0K

Compiler Diagnostics (tsc)

main (69ad885) #4703 (15fa50c) +/-
Files 303 303 0
Lines 141,175 141,175 0
Identifiers 128,951 128,951 0
Symbols 269,501 269,501 0
Types 202,701 202,701 0
Instantiations 609,801 609,801 0
Memory used 337,802K 345,468K 7,666K
I/O read 0.02s 0.02s 0s
I/O write 0s 0s 0s
Parse time 0.82s 0.71s -0.11s
Bind time 0.34s 0.29s -0.05s
Check time 2.7s 2.43s -0.27s
Emit time 0s 0s 0s
Total time 3.86s 3.44s -0.42s

Compiler Diagnostics (typescript-go)

main (69ad885) #4703 (15fa50c) +/-
Files 303 303 0
Lines 141,177 141,177 0
Identifiers 128,914 128,914 0
Symbols 391,801 390,831 -970
Types 372,904 372,904 0
Instantiations 984,004 984,004 0
Memory used 254,559K 254,296K -263K
Memory allocs 2,553,364 2,553,368 4
Config time 0.001s 0.001s 0s
Parse time 0.094s 0.089s -0.005s
Bind time 0.018s 0.032s 0.014s
Check time 0.664s 0.662s -0.002s
Emit time 0s 0s 0s
Total time 0.879s 0.836s -0.043s

Reported by octocov

@github-actions
Copy link

HTTP Performance Benchmark

Framework Runtime Average Ping Query Body
hono (origin/main) bun 36,250.33 51,487.53 31,447.69 25,815.78
hono (current) bun 36,828.68 52,801.24 31,930.02 25,754.77
Change +1.60% +2.55% +1.53% -0.24%

@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.44%. Comparing base (69ad885) to head (8bae958).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4703      +/-   ##
==========================================
+ Coverage   91.43%   91.44%   +0.01%     
==========================================
  Files         173      174       +1     
  Lines       11382    11396      +14     
  Branches     3302     3307       +5     
==========================================
+ Hits        10407    10421      +14     
  Misses        974      974              
  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.

@BelovedYaoo
Copy link

Hi @yusukebe, thanks for working on this!

I've opened #4714 as a follow-up optimization for this middleware. It introduces a WeakMap cache to store the result of the isMiddleware and findTargetHandler checks.

Since handler identities are immutable at runtime, this avoids redundant recursive lookups for every request, optimizing the performance from O(depth) to O(1) while remaining safe for dynamic routes.

Feel free to check it out :)

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.

Add configurable route existence check before authentication middleware execution

2 participants