11import { expect , test } from '@playwright/test' ;
22import { getSpanOp , waitForStreamedSpan } from '@sentry-internal/test-utils' ;
33
4- test ( 'should remove sentry-trace and baggage meta tags on ISR dynamic route page load' , async ( { page } ) => {
4+ const isProductionBuild = process . env . TEST_ENV === 'production' || process . env . TEST_ENV === 'prod-turbopack' ;
5+
6+ test ( 'does not carry trace meta tags on an ISR dynamic route' , async ( { page } ) => {
7+ // The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
8+ test . skip ( ! isProductionBuild , 'ISR pages are only prerendered in production builds' ) ;
9+
510 // Navigate to ISR page
611 await page . goto ( '/isr-test/laptop' ) ;
712
813 // Wait for page to be fully loaded
914 await expect ( page . locator ( '#isr-product-id' ) ) . toHaveText ( 'laptop' ) ;
1015
11- // Check that sentry-trace and baggage meta tags are removed for ISR pages
16+ // The shell was prerendered, and a prerender writes no trace tags
1217 await expect ( page . locator ( 'meta[name="sentry-trace"]' ) ) . toHaveCount ( 0 ) ;
1318 await expect ( page . locator ( 'meta[name="baggage"]' ) ) . toHaveCount ( 0 ) ;
1419} ) ;
1520
16- test ( 'should remove sentry-trace and baggage meta tags on ISR static route' , async ( { page } ) => {
21+ test ( 'does not carry trace meta tags on an ISR static route' , async ( { page } ) => {
22+ // The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
23+ test . skip ( ! isProductionBuild , 'ISR pages are only prerendered in production builds' ) ;
24+
1725 // Navigate to ISR static page
1826 await page . goto ( '/isr-test/static' ) ;
1927
2028 // Wait for page to be fully loaded
2129 await expect ( page . locator ( '#isr-static-marker' ) ) . toHaveText ( 'static-isr' ) ;
2230
23- // Check that sentry-trace and baggage meta tags are removed for ISR pages
31+ // The shell was prerendered, and a prerender writes no trace tags
2432 await expect ( page . locator ( 'meta[name="sentry-trace"]' ) ) . toHaveCount ( 0 ) ;
2533 await expect ( page . locator ( 'meta[name="baggage"]' ) ) . toHaveCount ( 0 ) ;
2634} ) ;
2735
28- test ( 'should remove meta tags for different ISR dynamic route values' , async ( { page } ) => {
36+ test ( 'does not carry trace meta tags for different ISR dynamic route values' , async ( { page } ) => {
37+ // The dev server renders ISR pages for every request, so there the trace tags are fresh and kept.
38+ test . skip ( ! isProductionBuild , 'ISR pages are only prerendered in production builds' ) ;
39+
2940 // Test with 'phone' (one of the pre-generated static params)
3041 await page . goto ( '/isr-test/phone' ) ;
3142 await expect ( page . locator ( '#isr-product-id' ) ) . toHaveText ( 'phone' ) ;
@@ -44,7 +55,7 @@ test('should remove meta tags for different ISR dynamic route values', async ({
4455test ( 'should create unique traces for ISR pages on each visit' , async ( { page } ) => {
4556 const traceIds : string [ ] = [ ] ;
4657
47- // Load the same ISR page 5 times to ensure cached HTML meta tags are consistently removed
58+ // Load the same ISR page 5 times: the cached HTML carries no trace tag, so every visit starts its own trace
4859 for ( let i = 0 ; i < 5 ; i ++ ) {
4960 const spanPromise = waitForStreamedSpan ( 'nextjs-16-cf-workers' , span => {
5061 return span . name === '/isr-test/:product' && getSpanOp ( span ) === 'pageload' && span . is_segment ;
@@ -64,7 +75,7 @@ test('should create unique traces for ISR pages on each visit', async ({ page })
6475 traceIds . push ( traceId ! ) ;
6576 }
6677
67- // Verify all 5 page loads have unique trace IDs (no reuse of cached/stale meta tags )
78+ // Verify all 5 page loads have unique trace IDs (no trace replayed from the cached HTML )
6879 const uniqueTraceIds = new Set ( traceIds ) ;
6980 expect ( uniqueTraceIds . size ) . toBe ( 5 ) ;
7081} ) ;
0 commit comments