feat(hono): export useLogger() and enable log.fork() - #476
Conversation
🦋 Changeset detectedLatest commit: 1160cda The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 9 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thank you for following the naming conventions! 🙏 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Hono was the only framework integration without `useLogger()`, so reaching
the request logger from a service or repository meant threading the Hono
`Context` down through every call. It now uses `createLoggerStorage()` like
every other integration and runs the downstream handler inside the storage.
`c.get('log')` is unchanged and stays the idiomatic accessor inside route
handlers — the two return the same logger. Attaching AsyncLocalStorage also
enables `log.fork()`, which Hono previously lacked (the docs called this
out).
Tradeoff: `evlog/hono` now imports `node:async_hooks` transitively via
`evlog/toolkit/storage`, so Cloudflare Workers deployments need the
`nodejs_compat` / `nodejs_als` flag. Documented on the Hono page and in the
changeset. `evlog/workers` is unaffected and stays async_hooks-free.
Updates AGENTS.md: the Hono carve-out is replaced by the general contract
every integration is now expected to satisfy.
006d53e to
423c38e
Compare
commit: |
|
@coderabbitai review |
✅ Action performedReview finished.
|
What
Hono was the last integration without
useLogger(). It now usescreateLoggerStorage()like every other one:c.get('log')is not removed or deprecated — both return the same logger.Bonus:
log.fork()Attaching AsyncLocalStorage also enables
log.fork()on Hono, which it previously lacked — the docs explicitly said so:Background work now emits its own wide event correlated to the request via
_parentRequestId.node:async_hookson WorkersThis is the reason Hono was carved out in the first place, so it deserves a straight answer.
evlog/hononow importsnode:async_hookstransitively throughevlog/toolkit/storage. I verified this against the built bundle:Cloudflare Workers deployments need
nodejs_compat(ornodejs_als) inwrangler.toml. Without it, the import fails at build/deploy time. This putsevlog/honoin the same position asexpress,fastify,nestjs,sveltekit,react-router,orpcandelysia, all of which already import it.evlog/workersis untouched and stays async_hooks-free — re-verified againstdist/workers.mjs(0 references). It remains the path for Workers deployments that cannot enable the flag.If you'd rather not take that on, the alternative is a separate
evlog/hono/loggersubpath so the base entry stays clean. I did not do that because it breaks the "same contract everywhere" goal — but say the word and I'll switch it.Docs & conventions
log.fork()note replaced with a working example, and a callout about the Workers flagAGENTS.md: theHono does not export useLogger()carve-out is replaced by the general contract every integration is now expected to satisfy, plus the documented reasonevlog/workersis the one exceptionVerification
pnpm run test— 1637/1637 pass (5 new: parity withc.get('log'), resolution through nested async calls, the out-of-request error, filtered-route behaviour, andlog.fork()emitting a correlated child event)pnpm run lint— 0 errors (2 pre-existingmax-paramswarnings innitro-v3/plugin.ts)pnpm run typecheck— 26/26 tasks passpnpm run api:snapshot— diff is+ "useLogger"on./honoonly