⚗ NextJS- add nextjs error boundary component#4352
⚗ NextJS- add nextjs error boundary component#4352BeltranBulbarellaDD wants to merge 14 commits intomainfrom
Conversation
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 9254f01 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
There was a problem hiding this comment.
Since all these tests are the same for rum-react (except for the last one) should I remove them?
package.json
Outdated
| "build:docs:json": "typedoc --logLevel Verbose --json ./docs.json", | ||
| "build:docs:html": "typedoc --out ./docs", | ||
| "pack": "yarn workspaces foreach --all --parallel --include '@datadog/*' exec yarn pack", | ||
| "pack": "yarn workspaces foreach --all --parallel --topological --include '@datadog/*' exec yarn pack", |
There was a problem hiding this comment.
This is required because rum-nextjs needs rum-react
There was a problem hiding this comment.
I'm not sure about this... rum depends on rum-code which depends on core and that was not an issue before.
There was a problem hiding this comment.
Hm let's discuss!
| stdout: 'pipe' as const, | ||
| cwd: path.join(__dirname, '../apps/nextjs'), | ||
| command: isLocal ? 'yarn dev' : 'yarn start', | ||
| command: 'yarn start', |
There was a problem hiding this comment.
This is for 2 reasons:
- So that StrictMode does not double-fires in dev mode.
- The dev error overlay does not appear (ex)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d7f0239ab
ℹ️ 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".
package.json
Outdated
| "build:docs:json": "typedoc --logLevel Verbose --json ./docs.json", | ||
| "build:docs:html": "typedoc --out ./docs", | ||
| "pack": "yarn workspaces foreach --all --parallel --include '@datadog/*' exec yarn pack", | ||
| "pack": "yarn workspaces foreach --all --parallel --topological --include '@datadog/*' exec yarn pack", |
There was a problem hiding this comment.
I'm not sure about this... rum depends on rum-code which depends on core and that was not an issue before.
| expect(customErrors[0].context).toMatchObject({ | ||
| framework: 'nextjs', | ||
| nextjs: { digest: expect.any(String) }, | ||
| }) |
There was a problem hiding this comment.
suggestion:
expect(errorEvent.error.component_stack).toBeDefined()There was a problem hiding this comment.
But we are not testing the same thing right? I don't mind the change I just wanted to test the nextjs specific values.
Motivation
Adds React error boundary to NextJS pages router.
Changes
Adds
ErrorBoundary— a React error boundary component that wrapscreateErrorBoundaryfrom@datadog/browser-rum-react, pre-wired to calladdNextjsError.Exports
ErrorBoundaryFallbackandErrorBoundaryPropstypes alongside it.Also adds
@datadog/browser-rum-reactas an optional peer dependency ofrum-nextjs, and allows@datadog/browser-rum-react/internalthrough thedisallow-side-effectsESLint rule.Test instructions
Test app — new pages for both routers to exercise all error paths:
pages-router/error-test.tsxerror.tsxsegment boundary callingaddNextjsErrorerror.tsxcallingaddNextjsErrorglobal-error.tsxcallingaddNextjsErrorChecklist