File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
e2e-tests/test-applications/nextjs-app-dir
app/edge-server-components/error Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ export const dynamic = 'force-dynamic' ;
2+
3+ export const runtime = 'edge' ;
4+
5+ export default async function Page ( ) {
6+ throw new Error ( 'Edge Server Component Error' ) ;
7+ }
Original file line number Diff line number Diff line change 1+ import { test , expect } from '@playwright/test' ;
2+ import { waitForError } from '../event-proxy-server' ;
3+
4+ test ( 'Should record exceptions for faulty edge server components' , async ( { page } ) => {
5+ const errorEventPromise = waitForError ( 'nextjs-13-app-dir' , errorEvent => {
6+ return errorEvent ?. exception ?. values ?. [ 0 ] ?. value === 'Edge Server Component Error' ;
7+ } ) ;
8+
9+ await page . goto ( '/edge-server-components/error' ) ;
10+
11+ expect ( await errorEventPromise ) . toBeDefined ( ) ;
12+ } ) ;
Original file line number Diff line number Diff line change 11import {
22 addTracingExtensions ,
33 captureException ,
4+ flush ,
45 getCurrentHub ,
56 runWithAsyncContext ,
67 startTransaction ,
@@ -81,6 +82,7 @@ export function wrapServerComponentWithSentry<F extends (...args: any[]) => any>
8182 maybePromiseResult = originalFunction . apply ( thisArg , args ) ;
8283 } catch ( e ) {
8384 handleErrorCase ( e ) ;
85+ void flush ( ) ;
8486 throw e ;
8587 }
8688
@@ -94,12 +96,14 @@ export function wrapServerComponentWithSentry<F extends (...args: any[]) => any>
9496 handleErrorCase ( e ) ;
9597 } ,
9698 ) ;
99+ void flush ( ) ;
97100
98101 // It is very important that we return the original promise here, because Next.js attaches various properties
99102 // to that promise and will throw if they are not on the returned value.
100103 return maybePromiseResult ;
101104 } else {
102105 transaction . finish ( ) ;
106+ void flush ( ) ;
103107 return maybePromiseResult ;
104108 }
105109 } ) ;
You can’t perform that action at this time.
0 commit comments