-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathstreaming-rsc-error.test.ts
More file actions
38 lines (31 loc) · 1.43 KB
/
streaming-rsc-error.test.ts
File metadata and controls
38 lines (31 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { expect, test } from '@playwright/test';
import { waitForError, waitForTransaction } from '@sentry-internal/test-utils';
test('Should capture errors for crashing streaming promises in server components when `Sentry.captureRequestError` is added to the `onRequestError` hook', async ({
page,
}) => {
const errorEventPromise = waitForError('nextjs-16-cf-workers', errorEvent => {
return !!errorEvent?.exception?.values?.some(value => value.value === 'I am a data streaming error');
});
const serverTransactionPromise = waitForTransaction('nextjs-16-cf-workers', async transactionEvent => {
return transactionEvent?.transaction === 'GET /streaming-rsc-error/[param]';
});
await page.goto(`/streaming-rsc-error/123`);
const errorEvent = await errorEventPromise;
const serverTransactionEvent = await serverTransactionPromise;
// error event is part of the transaction
expect(errorEvent.contexts?.trace?.trace_id).toBe(serverTransactionEvent.contexts?.trace?.trace_id);
expect(errorEvent.request).toMatchObject({
headers: expect.any(Object),
method: 'GET',
});
expect(errorEvent.contexts?.nextjs).toEqual({
route_type: 'render',
router_kind: 'App Router',
router_path: '/streaming-rsc-error/[param]',
request_path: '/streaming-rsc-error/123',
});
expect(errorEvent.exception?.values?.[0]?.mechanism).toEqual({
handled: false,
type: 'auto.function.nextjs.on_request_error',
});
});