Skip to content

refactor(server): simplify router middleware with next()#21720

Open
thdxr wants to merge 10 commits intodevfrom
server-cleanup
Open

refactor(server): simplify router middleware with next()#21720
thdxr wants to merge 10 commits intodevfrom
server-cleanup

Conversation

@thdxr
Copy link
Copy Markdown
Member

@thdxr thdxr commented Apr 9, 2026

Summary

Refactors the server router middleware to use Hono's next() function instead of manually invoking routes.

Changes

  • Removed unused imports (lazy, InstanceRoutes)
  • Removed lazy initialization of routes
  • Added next parameter to middleware handler
  • Replaced routes().fetch(c.req.raw, c.env) calls with next()

This simplifies the middleware by leveraging Hono's built-in middleware flow control.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

thdxr added 10 commits April 9, 2026 22:46
…quest processing

- Moves error handler registration to the root app instead of each sub-route
- Ensures consistent error responses across all API endpoints
- Removes unused imports and simplifies route composition
…ver.Default() synchronous

Removes unnecessary await calls on Server.Default() throughout the codebase, simplifying the server initialization flow and removing async overhead for faster startup.
Enables running the agent on Bun runtime in addition to Node.js by
abstracting server initialization into runtime-specific adapters. The
server will automatically use Bun's native APIs when available.
The previous test was measuring heap growth while running inside the shared
Instance context, which included unrelated tool runtime state that could
obscure the actual abort controller leak signal.

Now the fetch operations run in a dedicated Bun worker process, giving a
clean baseline for memory measurement that accurately reflects whether
abort listeners are being properly cleaned up after timed fetches.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant