✨ NextJS- addNextjsError component#4343
Conversation
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 7fc18f4 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
|
|
||
| await flushEvents() | ||
|
|
||
| // React StrictMode double-fires useEffect in dev mode, so we may get 2 errors |
There was a problem hiding this comment.
❓ question: Any reason to use dev mode?
There was a problem hiding this comment.
In local we use dev and in the CI we use the prod one. I thought it would cover all cases but we could just do prod. WDYT?
There was a problem hiding this comment.
Shouldn’t this double fire also happen with the React plugin? How do we handle it there?
There was a problem hiding this comment.
Yeah we do the same "optimistic check" this is what React does:
toBeGreaterThan(0)
There was a problem hiding this comment.
Okay so you can keep it like this :)
| startClocks, | ||
| context: { | ||
| ...(error as Error & { dd_context?: Context }).dd_context, | ||
| ...(error.digest && { nextjs: { digest: error.digest } }), |
There was a problem hiding this comment.
❓ question: Should nextjs.digest part of the rum-evens-format
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
|
|
||
| await flushEvents() | ||
|
|
||
| // React StrictMode double-fires useEffect in dev mode, so we may get 2 errors |
There was a problem hiding this comment.
Okay so you can keep it like this :)
Motivation
This PR adds error reporting support to
@datadog/browser-rum-nextjsfor the App Router.Changes
packages/rum-nextjs
addNextjsError(error, errorInfo?)— a new public API, mirroringaddReactErrorfromrum-react, for reporting errors from Next.js App Router error boundaries (error.tsx,global-error.tsx) and from createRoot's onUncaughtError / onRecoverableError hooksnextjsPluginto useaddErrorinstead ofaddEvent, aligning with how reactPlugin worksaddNextjsErrorfrom the package entry pointpackages/core
'nextjs error'as a validcreateHandlingStacktypetest/apps/nextjs
/error-test,/error-test/server-error,/global-error-test, andglobal-error.tsxto exercise client, server digest, and global error scenariostest/e2e
addNextjsErroraddNextjsErrorglobal-error.tsxTest instructions
You can build the test app:
yarn install && yarn build && yarn build:apps cd test/apps/nextjs/ yarn devChecklist