fix(nitro): allow useLogger() in server middleware#215
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Thank you for following the naming conventions! 🙏 |
Contributor
Benchmark reportBundle size
|
commit: |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Nitro/Nuxt server middleware compatibility by ensuring a request-scoped evlog logger is always attached to the event context (so useLogger(event) won’t throw), while still honoring route include/exclude filtering at emit time.
Changes:
- Always create the request logger in Nitro v2/v3
requesthooks, storing a new_evlogShouldEmitflag for later guards. - Skip emission in
afterResponse/responseanderrorhooks when_evlogShouldEmitis false. - Add a changeset and new tests aimed at covering the middleware scenario.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/evlog/src/nitro/plugin.ts | Always creates logger; adds _evlogShouldEmit and uses it to guard emission in hooks. |
| packages/evlog/src/nitro-v3/plugin.ts | Same behavior for Nitro v3 plugin (request always creates logger; response/error gated). |
| packages/evlog/src/types.ts | Adds _evlogShouldEmit?: boolean to H3EventContext. |
| packages/evlog/test/nitro-plugin.test.ts | Adds new “middleware compatibility” tests (currently not effectively exercising the plugin). |
| .changeset/fix-middleware-uselogger.md | Patch release note describing the behavioral change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address Copilot review feedback: the previous tests were tautological (manually setting values and asserting them back). New tests replicate the plugin's request/afterResponse/error hook logic and invoke it against real createRequestLogger instances, verifying observable behavior (logger creation, emit gating, error propagation).
This was referenced Mar 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
Resolves #210
📚 Description
📝 Checklist