chore(deps): update dependency @hono/node-server to v2#238
Conversation
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3899188607
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| "hono": "^4" | ||
| } | ||
| }, | ||
| "node_modules/@isaacs/cliui": { |
There was a problem hiding this comment.
Restore @hono/node-server package entry in lockfile
This change removes the node_modules/@hono/node-server block from prisma/package-lock.json without replacing it with a v2 resolved entry, even though the same lockfile still declares @prisma/dev depends on @hono/node-server. That leaves the lockfile unable to fully describe the dependency tree, so installs can become non-reproducible (or fail in stricter CI/registry-policy environments) because npm must re-resolve this transitive package at install time instead of using a locked version.
Useful? React with 👍 / 👎.
This PR contains the following updates:
^1.19.13→^2.0.0Release Notes
honojs/node-server (@hono/node-server)
v2.0.6Compare Source
v2.0.5Compare Source
Security Fix
Fixed a security issue in Serve Static Middleware where prefix-mounted middleware could be bypassed on Windows. This only affects applications running on Windows that use Serve Static Middleware. Affected users are encouraged to upgrade to this version.
See GHSA-frvp-7c67-39w9 for details.
v2.0.4Compare Source
What's Changed
Full Changelog: honojs/node-server@v2.0.3...v2.0.4
v2.0.3Compare Source
What's Changed
ServeStaticOptionscomment with the current spec by @kakkokari-gtyih in #356New Contributors
Full Changelog: honojs/node-server@v2.0.2...v2.0.3
v2.0.2Compare Source
What's Changed
Full Changelog: honojs/node-server@v2.0.1...v2.0.2
v2.0.1Compare Source
What's Changed
New Contributors
Full Changelog: honojs/node-server@v2.0.0...v2.0.1
v2.0.0Compare Source
Now, we release the second major version of the Hono Node.js adapter 🎉 🎉 🎉
The Hono Node.js adapter is now up to 2.3x faster
v2 of the Hono Node.js adapter reaches up to 2.3x the throughput of v1 — that's the peak number, measured on the body-parsing scenario of
bun-http-framework-benchmark. The other scenarios (Ping, Query) get a smaller but real boost too.Install or upgrade with:
v2
The Node.js adapter is going through a major version bump to v2. That said, the public API stays the same — the headline of this release is the large performance improvement described above.
What does the Node.js adapter do?
A quick refresher on what the Node.js adapter actually does — it exists so that Hono applications can run on Node.js. Hono is built on the Web Standards APIs, but you cannot serve those directly from Node.js. The adapter bridges the Web Standards APIs and the Node.js APIs, which is what lets a Hono app — and more generally a Web-Standards-style app — run on top of Node.js.
If you write the following code and run
node ./index.js, a server starts up onlocalhost:3000. And it really is plain Node.js underneath.The early performance story
The very first implementation of the Node.js adapter looked roughly like this in pseudocode:
So the flow was:
IncomingMessageRequestobject and handed to the appResponsereturned by the app is written back to the outgoingServerResponseIn diagram form:
This is, frankly, inefficient. So whenever Hono went head-to-head with other Node.js frameworks we kept losing — all we could do was shrug and say "well, it's slow on Node.js."
Introducing LightweightRequest / LightweightResponse
The huge step forward that fixed this was a legendary PR from @usualoma:
#95
It made things up to 2.7x faster.
I previously wrote about this in detail in this post:
https://zenn.dev/yusukebe/articles/7ac501716ae1f7?locale=en
In short, the trick is wonderfully simple. It just follows the golden rule of performance tuning: don't do work you don't have to do. Lightweight versions of
RequestandResponseare constructed and used first — and that path is fast. Only when something actually needs the contents of theRequest, e.g. when you callreq.json(), does a realnew Request()get instantiated under the hood and used from then on. The result is fast, and behavior stays correct.…but body parsing was still slow
"Fast" here was for a very simple "Hello World" benchmark — a GET that just returns text.
There are many ways to benchmark, but the one we tend to reach for is this:
https://github.com/SaltyAom/bun-http-framework-benchmark
It tests three scenarios: Ping, Query, and Body. Let's pit Hono against the major Node.js frameworks:
As you can see, the Body case is very slow. The handler being measured is essentially this:
c.req.json()is the slow part. The reason is well understood: inside the Node.js adapter, whenjson()is called the LightweightRequest path can't be used, so a realnew Request()ends up being constructed.perf: optimize request body reading
The 2.3x figure above comes from one PR specifically — PR #301 by @mgcrea:
The PR bundles a few changes, but the key one is "optimize request body reading". Quoting from the PR description:
In other words, in the
json()case above, we no longer convert into aRequestat all — we read the body straight off the Node.js APIs. A classic fast path. That alone gives a large jump in body-parsing throughput.The same PR also includes two other tuning improvements:
URLobject except in edge casesbuildOutgoingHttpHeadersoptimization — skip theset-cookieheader comparison when there are no cookiesv2 ships several other performance PRs as well —
newHeadersFromIncomingand signal fast-paths,Responsefast-paths andresponseViaCacheimprovements, method-key caching, a regex-basedbuildUrlrewrite, and more (see the full list below). They all add up, but #301 is by far the largest single contributor, which is why it gets the spotlight here.v2 performance
Now let's measure the final v2 build.
First, comparing against the v1 Node.js adapter.
devhere is v2. Body improves by 2.3x, and the other scenarios get faster too:Next, the same comparison against other frameworks. With the Body score jumping, Hono passes Koa and Fastify and takes first place:
Breaking changes
There are two breaking changes in v2.
Dropped support for Node.js v18
Node.js v18 reached end-of-life, so v2 requires Node.js v20 or later.
Removed the Vercel adapter
The Vercel adapter (
@hono/node-server/vercel) has been removed. It is no longer needed for Vercel's modern runtimes, so the recommendation is to deploy without it.If you still need the previous behavior, the old adapter was a one-liner on top of
getRequestListenerand you can write the same thing in your own project:Then use it the same way you used
handlefrom@hono/node-server/vercelbefore.All changes
A full list of what landed in PR #316.
Performance
buildOutgoingHttpHeadersfor the common case (#301) by @mgcrea:as safe host (#320) by @yusukebenewHeadersFromIncomingand signal fast-path (#332) by @GavinMeierSonosResponsefast-paths andresponseViaCacheimprovements (#333) by @GavinMeierSonosUint8Arraylookup tables with regex inbuildUrl(#345) by @usualomaFeatures
Breaking changes
Fixes & refactors
new URL()should be used (#310) by @usualomaRequestobject (#311) by @usualomaBlob/ReadableStreamcacheable responses (#342) by @usualomaResponse.json()andResponse.redirect()spec compliance and efficiency (#343) by @usualomaBuild & tooling
type: moduletopackage.json(#336) by @yusukebeWrap-up
So that's v2 of the Node.js adapter — significantly faster, with the same API. Just upgrading should give you a real performance boost. No more "Hono is slow on Node.js" excuses. Please use Hono — fast not only on Cloudflare, Bun, and Deno, but now also on Node.js.
Configuration
📅 Schedule: (UTC)
* 0-3 * * 1)🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.