Skip to content

fix(nitro): skip default error logging when evlog records the request - #837

Merged
HugoRCD merged 1 commit into
mainfrom
fix/nitro-no-duplicate-error-log
Oct 11, 2026
Merged

HugoRCD merged 1 commit into
mainfrom
fix/nitro-no-duplicate-error-log

Conversation

@HugoRCD

@HugoRCD HugoRCD commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

🔗 Linked issue

Follow-up to #819. Found while testing the release candidate in a Nuxt app.

📚 Description

#819 stopped Nitro from printing expected evlog 4xx errors, but kept its default logging for everything else. In production, an unhandled crash or a fatal h3 error still printed twice: once as the wide event, and once as Nitro's [request error] [unhandled] block with the full stack and the h3 error object.

{"level":"error","path":"/api/crash","status":500,"error":{"message":"Cannot read properties of undefined (reading 'code')", ...}, ...}
[request error] [unhandled] [GET] http://localhost:3143/api/crash
 TypeError: Cannot read properties of undefined (reading 'code')
    at Object.handler (.output/server/chunks/routes/api/crash.get.mjs:21:25)
    ...

Change

evlog's error handler only calls ctx.defaultHandler(..., { silent: false }) to get that log, since it writes the response itself. It now skips the call whenever the evlog plugin records the request (_evlogShouldEmit, set in the request hook), for both Nitro v2 and v3. Nitro still logs the error when evlog is disabled, the route is excluded with include/exclude, or the plugin is not registered, so an error is never silent.

The check uses _evlogShouldEmit and not _evlogEmitted: Nitro v2 doesn't await the error hook before running the error handler, so the emitted flag isn't set yet at that point.

Not covered: Nuxt's own error handler calls defaultHandler with silent: false for HTML page requests, which evlog's handler passes on to it. So an SSR page crash still prints Nitro's block.

Tests

  • Nitro v2 and v3: an unhandled TypeError and a fatal 503 on a recorded request don't call defaultHandler. An excluded route still does.
  • The evlog suite passes (2,121 tests), along with build and lint.
  • Checked in a production Nuxt build: /api/crash and /api/upstream print only their wide event.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • Bug Fixes
    • Prevented duplicate error logging when Evlog has already recorded an error. Nitro’s default logging remains active when Evlog is disabled, a route is excluded, or the Evlog plugin is not registered.

@vercel

vercel Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
evi Ready Ready Preview Oct 11, 2026 8:54pm UTC
evlog-docs Ready Ready Preview, v0 Oct 11, 2026 8:54pm UTC
evlog-render-lab Ready Ready Preview Oct 11, 2026 8:54pm UTC
evlog-telemetry Ready Ready Preview Oct 11, 2026 8:54pm UTC
just-use-evlog Ready Ready Preview Oct 11, 2026 8:54pm UTC

Request Review

@github-actions github-actions Bot added the bug Something isn't working label Oct 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@pkg-pr-new

pkg-pr-new Bot commented Oct 11, 2026

Copy link
Copy Markdown
@evlog/cli

npm i https://pkg.pr.new/@evlog/cli@837

evlog

npm i https://pkg.pr.new/evlog@837

@evlog/nuxthub

npm i https://pkg.pr.new/@evlog/nuxthub@837

@evlog/signals

npm i https://pkg.pr.new/@evlog/signals@837

@evlog/telemetry

npm i https://pkg.pr.new/@evlog/telemetry@837

commit: 3c5f8ff

@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: df681506-e442-4949-91e8-cc8478d736ab

📥 Commits

Reviewing files that changed from the base of the PR and between f3613ee and 3c5f8ff.


📒 Files selected for processing (6)
  • .changeset/nitro-no-duplicate-error-log.md
  • packages/evlog/src/nitro-v3/errorHandler.ts
  • packages/evlog/src/nitro.ts
  • packages/evlog/src/nitro/errorHandler.ts
  • packages/evlog/test/nitro-v3/errorHandler.test.ts
  • packages/evlog/test/nitro/errorHandler.test.ts

 ____________________________________________
< 99 little bugs in the code... I filed 100. >
 --------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@HugoRCD
HugoRCD merged commit b3b3b35 into main Oct 11, 2026
21 of 22 checks passed
@HugoRCD
HugoRCD deleted the fix/nitro-no-duplicate-error-log branch October 11, 2026 20:58

This branch was successfully deployed

5 active deployments
Preview – evlog-telemetry — 3c5f8ff5 Deployed Oct 11, 2026 by vercel[bot]
Preview – evi — 3c5f8ff5 Deployed Oct 11, 2026 by vercel[bot]
Preview – evlog-docs — 3c5f8ff5 Deployed Oct 11, 2026 by vercel[bot]
Preview – just-use-evlog — 3c5f8ff5 Deployed Oct 11, 2026 by vercel[bot]
Preview – evlog-render-lab — 3c5f8ff5 Deployed Oct 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant