Skip to content

🐛 [rum-nuxt] Fix Nuxt post-hydration error handling#4899

Merged
BeltranBulbarellaDD merged 2 commits into
mainfrom
beltran.bulbarella/fix-rum-nuxt-hydration-error
Jul 21, 2026
Merged

🐛 [rum-nuxt] Fix Nuxt post-hydration error handling#4899
BeltranBulbarellaDD merged 2 commits into
mainfrom
beltran.bulbarella/fix-rum-nuxt-hydration-error

Conversation

@BeltranBulbarellaDD

@BeltranBulbarellaDD BeltranBulbarellaDD commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Motivation

Issue.

Nuxt installs its default vueApp.config.errorHandler during initial rendering and removes it after hydration on app:suspense:resolve, as long as the handler was not overridden.

The Nuxt RUM plugin wraps that handler before hydration, which prevents Nuxt’s identity check from removing it. As a result, client-side Vue errors triggered after hydration keep delegating to Nuxt’s default error handler and render the full-page error.vue, even though Nuxt would normally only log them to the console.

Changes

  • Stop delegating to Nuxt’s default error handler after app:suspense:resolve.
  • Continue reporting Vue errors to RUM after hydration.
  • Preserve the original behavior before hydration so initial render/startup errors can still trigger Nuxt’s error page.
  • Keep delegating to custom original Vue error handlers after hydration.
  • Add unit coverage for Nuxt default handler gating and custom handler preservation.
  • Added e2e test.

Test instructions

  1. Checkout main.
  2. Start the Nuxt test app.
  3. Open the Nuxt error test page without RUM.
  4. Click Trigger Error.
  5. Confirm the error is only logged to the console and the app does not render the Nuxt error page.
  6. Open the same page with: ?rum-config={"applicationId":"test","clientToken":"test","site":"datadoghq.com"}
  7. Click Trigger Error.
  8. On main, confirm the app renders the Nuxt 500 Internal Server Error page.
  9. With this fix, confirm the error is reported to RUM but the app stays on the page and only logs the error to the console.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 178.53 KiB 178.53 KiB 0 B 0.00%
Rum Profiler 8.22 KiB 8.22 KiB 0 B 0.00%
Rum Recorder 21.12 KiB 21.12 KiB 0 B 0.00%
Logs 55.59 KiB 55.59 KiB 0 B 0.00%
Rum Salesforce N/A 136.60 KiB N/A N/A N/A
Rum Slim 136.60 KiB 136.60 KiB 0 B 0.00%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jul 21, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 57.14%
Overall Coverage: 77.19% (-0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9b5cc2e | Docs | Datadog PR Page | Give us feedback!

@BeltranBulbarellaDD BeltranBulbarellaDD changed the title 🐛 [rum-nuxt] Fix uncaught error after hydration render. 🐛 [rum-nuxt] Fix Nuxt post-hydration error handling Jul 21, 2026
@BeltranBulbarellaDD

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: bf131bfd1c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@BeltranBulbarellaDD
BeltranBulbarellaDD marked this pull request as ready for review July 21, 2026 10:43
@BeltranBulbarellaDD
BeltranBulbarellaDD requested a review from a team as a code owner July 21, 2026 10:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf131bfd1c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

let shouldCallOriginal = true

nuxtApp.hook('app:suspense:resolve', () => {
if (isNuxtDefaultErrorHandler(original)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Support untagged Nuxt 3 default handlers

issue: This only disables delegation when Nuxt marks its default handler with __nuxt_default, but supported Nuxt 3 releases such as 3.11.2 install handleVueError without that marker and clear it after mount via an identity check instead (Nuxt 3.11.2 source). Because this wrapper has already replaced vueApp.config.errorHandler, Nuxt cannot clear its default handler, and this condition never flips shouldCallOriginal, so post-hydration client errors in those Nuxt 3 apps still delegate to Nuxt's default handler and render the full-page error.

Useful? React with 👍 / 👎.

@bdibon bdibon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good job! A couple of suggestions to improve tests readability.

Comment thread packages/browser-rum-nuxt/src/domain/error/setupNuxtErrorHandling.spec.ts Outdated
Comment thread test/e2e/scenario/plugins/nuxtPlugin.scenario.ts Outdated
@BeltranBulbarellaDD
BeltranBulbarellaDD merged commit d5f75e4 into main Jul 21, 2026
31 checks passed
@BeltranBulbarellaDD
BeltranBulbarellaDD deleted the beltran.bulbarella/fix-rum-nuxt-hydration-error branch July 21, 2026 14:51
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants