-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nextjs): Don't report React postpone errors (#12194)
- Loading branch information
Showing
4 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
dev-packages/e2e-tests/test-applications/nextjs-15/app/ppr-error/[param]/page.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as Sentry from '@sentry/nextjs'; | ||
|
||
export default async function Page({ | ||
searchParams, | ||
}: { | ||
searchParams: { id?: string }; | ||
}) { | ||
try { | ||
console.log(searchParams.id); // Accessing a field on searchParams will throw the PPR error | ||
} catch (e) { | ||
Sentry.captureException(e); // This error should not be reported | ||
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for any async event processors to run | ||
await Sentry.flush(); | ||
throw e; | ||
} | ||
|
||
return <div>This server component will throw a PPR error that we do not want to catch.</div>; | ||
} |
6 changes: 5 additions & 1 deletion
6
dev-packages/e2e-tests/test-applications/nextjs-15/next.config.js
This file contains 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
22 changes: 22 additions & 0 deletions
22
dev-packages/e2e-tests/test-applications/nextjs-15/tests/ppr-error.test.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { waitForError, waitForTransaction } from '@sentry-internal/event-proxy-server'; | ||
|
||
test('should not capture React-internal errors for PPR rendering', async ({ page }) => { | ||
const pageServerComponentTransactionPromise = waitForTransaction('nextjs-15', async transactionEvent => { | ||
return transactionEvent?.transaction === 'Page Server Component (/ppr-error/[param])'; | ||
}); | ||
|
||
let errorEventReceived = false; | ||
waitForError('nextjs-15', async transactionEvent => { | ||
return transactionEvent?.transaction === 'Page Server Component (/ppr-error/[param])'; | ||
}).then(() => { | ||
errorEventReceived = true; | ||
}); | ||
|
||
await page.goto(`/ppr-error/foobar?id=1`); | ||
|
||
const pageServerComponentTransaction = await pageServerComponentTransactionPromise; | ||
expect(pageServerComponentTransaction).toBeDefined(); | ||
|
||
expect(errorEventReceived).toBe(false); | ||
}); |
This file contains 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