11import test , { expect } from '@playwright/test' ;
22import { waitForError , waitForTransaction } from '@sentry-internal/test-utils' ;
3+ import { isTurbopackDevMode } from './isDevMode' ;
34
45test ( 'Should create a transaction for node route handlers' , async ( { request } ) => {
6+ test . skip ( isTurbopackDevMode , 'Turbopack intermittently returns 404 for dynamic routes in dev mode' ) ;
7+
58 const routehandlerTransactionPromise = waitForTransaction ( 'nextjs-16' , async transactionEvent => {
69 return transactionEvent ?. transaction === 'GET /route-handler/[xoxo]/node' ;
710 } ) ;
@@ -13,11 +16,7 @@ test('Should create a transaction for node route handlers', async ({ request })
1316
1417 expect ( routehandlerTransaction . contexts ?. trace ?. status ) . toBe ( 'ok' ) ;
1518 expect ( routehandlerTransaction . contexts ?. trace ?. op ) . toBe ( 'http.server' ) ;
16-
17- // This is flaking on dev mode
18- if ( process . env . TEST_ENV !== 'development' && process . env . TEST_ENV !== 'dev-turbopack' ) {
19- expect ( routehandlerTransaction . contexts ?. trace ?. data ?. [ 'http.request.header.x_charly' ] ) . toBe ( 'gomez' ) ;
20- }
19+ expect ( routehandlerTransaction . contexts ?. trace ?. data ?. [ 'http.request.header.x_charly' ] ) . toBe ( 'gomez' ) ;
2120} ) ;
2221
2322test ( 'Should create a transaction for edge route handlers' , async ( { request } ) => {
@@ -41,6 +40,8 @@ test('Should create a transaction for edge route handlers', async ({ request })
4140test ( 'Should report an error with a parameterized transaction name for a throwing route handler' , async ( {
4241 request,
4342} ) => {
43+ test . skip ( isTurbopackDevMode , 'Turbopack intermittently returns 404 for dynamic routes in dev mode' ) ;
44+
4445 const errorEventPromise = waitForError ( 'nextjs-16' , errorEvent => {
4546 return errorEvent ?. exception ?. values ?. some ( value => value . value === 'route-handler-error' ) ?? false ;
4647 } ) ;
@@ -63,23 +64,6 @@ test('Should report an error with a parameterized transaction name for a throwin
6364 // Error should carry the parameterized transaction name
6465 expect ( errorEvent . transaction ) . toBe ( 'GET /route-handler/[xoxo]/error' ) ;
6566
66- // On turbopack (no wrapping loader), the error goes through onRequestError which sets nextjs context.
67- // On webpack, the wrapping loader's error handler fires first and captures without nextjs context.
68- // The SDK deduplicates by error identity, so only the first capture survives.
69- if ( process . env . TEST_ENV === 'development' ) {
70- expect ( errorEvent . contexts ?. nextjs ) . toEqual ( {
71- route_type : 'route' ,
72- router_kind : 'App Router' ,
73- router_path : '/route-handler/[xoxo]/error' ,
74- request_path : '/route-handler/456/error' ,
75- } ) ;
76-
77- expect ( errorEvent . exception ?. values ?. [ 0 ] ?. mechanism ) . toEqual ( {
78- handled : false ,
79- type : 'auto.function.nextjs.on_request_error' ,
80- } ) ;
81- }
82-
8367 // Transaction should have parameterized name and internal_error status
8468 expect ( transactionEvent . transaction ) . toBe ( 'GET /route-handler/[xoxo]/error' ) ;
8569 expect ( transactionEvent . contexts ?. trace ?. status ) . toBe ( 'internal_error' ) ;
@@ -88,6 +72,8 @@ test('Should report an error with a parameterized transaction name for a throwin
8872test ( 'Should set a parameterized transaction name on a captureMessage event in a route handler' , async ( {
8973 request,
9074} ) => {
75+ test . skip ( isTurbopackDevMode , 'Turbopack intermittently returns 404 for dynamic routes in dev mode' ) ;
76+
9177 const messageEventPromise = waitForError ( 'nextjs-16' , event => {
9278 return event ?. message === 'route-handler-message' ;
9379 } ) ;
@@ -119,6 +105,8 @@ test('Should set a parameterized transaction name on a captureMessage event in a
119105test ( 'Should set a parameterized transaction name on a captureException event in a route handler' , async ( {
120106 request,
121107} ) => {
108+ test . skip ( isTurbopackDevMode , 'Turbopack intermittently returns 404 for dynamic routes in dev mode' ) ;
109+
122110 const errorEventPromise = waitForError ( 'nextjs-16' , errorEvent => {
123111 return errorEvent ?. exception ?. values ?. some ( value => value . value === 'route-handler-capture-exception' ) ?? false ;
124112 } ) ;
0 commit comments