Skip to content

Commit 576a529

Browse files
chargomeclaude
andcommitted
test(nextjs): Cover an ISR page that is prerendered again at runtime
The ISR shells of the e2e apps come from the build, where the SDK does not run, so the tag assertions passed with or without the guard. A page with a one second window makes the server prerender it again inside a request. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 84f41c3 commit 576a529

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// A short revalidation window, so a test can make the server prerender this page again at runtime.
2+
export const revalidate = 1;
3+
4+
export default function ISRRuntimePage() {
5+
return (
6+
<div>
7+
<h1>ISR Runtime Page</h1>
8+
<div id="isr-runtime-rendered-at">{Date.now()}</div>
9+
</div>
10+
);
11+
}

‎dev-packages/e2e-tests/test-applications/nextjs-16/tests/isr-routes.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,27 @@ test('ISR route should be identified correctly in the route manifest', async ({
9292
expect(span.name).toBe('/isr-test/:product');
9393
expect(span.attributes['sentry.segment.name.source']?.value).toBe('route');
9494
});
95+
96+
test('does not carry trace meta tags on an ISR page that was prerendered again at runtime', async ({ page }) => {
97+
test.skip(!isProductionBuild, 'ISR pages are only prerendered in production builds');
98+
99+
// The first visit serves the shell from the build. Once its revalidation window passed, a visit serves the stale
100+
// shell and makes the server prerender the page again, inside that request, with the SDK running. The visits after
101+
// that serve the shell from that prerender.
102+
await page.goto('/isr-test/runtime');
103+
const renderedAtBuild = await page.locator('#isr-runtime-rendered-at').textContent();
104+
105+
await expect
106+
.poll(
107+
async () => {
108+
await page.waitForTimeout(1500);
109+
await page.goto('/isr-test/runtime');
110+
return page.locator('#isr-runtime-rendered-at').textContent();
111+
},
112+
{ timeout: 30_000 },
113+
)
114+
.not.toBe(renderedAtBuild);
115+
116+
await expect(page.locator('meta[name="sentry-trace"]')).toHaveCount(0);
117+
await expect(page.locator('meta[name="baggage"]')).toHaveCount(0);
118+
});

0 commit comments

Comments
 (0)