Skip to content

Conversation

@aquapi
Copy link
Contributor

@aquapi aquapi commented Feb 8, 2026

  • avoid allocating a closure & a promise if handler is not asynchronous for applyHandler()
  • avoid allocating a promise in handle(middleware, pathname)
  • Change if (a.b == null) a.b = x to a.b ??= x and similar patterns
  • (I forgot to mention in the commit) remove setImmediate usage: https://blog.platformatic.dev/the-dangers-of-setimmediate

aquapi and others added 2 commits February 8, 2026 22:18
- avoid allocating a closure & a promise if handler is not asynchronous for applyHandler()
- avoid allocating a promise in handle(middleware, pathname)
- Change "if (a.b == null) a.b = x" to "a.b ??= x" and similar patterns
TypeScript doesn't narrow the Handler union type based on the
Symbol.toStringTag runtime check, so we need to cast the result
to Promise<void> when calling .catch().

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@v1rtl v1rtl merged commit 962c6ab into tinyhttp:master Feb 8, 2026
3 checks passed
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.

2 participants