Skip to content

Comments

perf(middleware): optimize route-check with WeakMap cache#4714

Open
BelovedYaoo wants to merge 1 commit intohonojs:feat/route-check-middlewarefrom
BelovedYaoo:feat/route-check-middleware
Open

perf(middleware): optimize route-check with WeakMap cache#4714
BelovedYaoo wants to merge 1 commit intohonojs:feat/route-check-middlewarefrom
BelovedYaoo:feat/route-check-middleware

Conversation

@BelovedYaoo
Copy link

@BelovedYaoo BelovedYaoo commented Feb 11, 2026

perf(middleware): optimize route-check with WeakMap cache (for #4703)

Introduces a WeakMap cache to avoid redundant findTargetHandler and isMiddleware recursive checks on every request. Since handler identity is immutable at runtime, caching the result reduces overhead from O(depth) recursion to O(1) lookup.

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

 - Avoid redundant recursive handler checks for every request by caching the result.
@BelovedYaoo BelovedYaoo marked this pull request as ready for review February 11, 2026 02:20
@BelovedYaoo BelovedYaoo changed the title perf(middleware): optimize route-check with WeakMap cache [WIP] perf(middleware): optimize route-check with WeakMap cache Feb 11, 2026
@BelovedYaoo BelovedYaoo changed the title [WIP] perf(middleware): optimize route-check with WeakMap cache perf(middleware): optimize route-check with WeakMap cache Feb 11, 2026
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.

1 participant