Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect, test } from '@playwright/test';
import { waitForTransaction } from '@sentry-internal/test-utils';

// The pageload should connect to the live serving request even though the shell is prerendered

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a live serving request?

// (trace context can only travel in the dynamic/resumed part of the response, never in cacheable
// HTML). The inverse assertion in cacheComponents.spec.ts ("Prerendered shell does not stitch
// the pageload onto a stale trace") documents today's un-connectedness.
test('connects the pageload trace to the live serving request', async ({ page }) => {
test.fail();

const serverTxPromise = waitForTransaction('nextjs-16-cacheComponents', transactionEvent => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double checking, if this is prerendered during the build, we get no tx here right? Can we reflect this in the test?

return (
transactionEvent.contexts?.trace?.op === 'http.server' && transactionEvent.transaction === 'GET /pageload-tracing'
);
});

const pageloadTxPromise = waitForTransaction('nextjs-16-cacheComponents', transactionEvent => {
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === '/pageload-tracing';
});

await page.goto('/pageload-tracing');

await expect(page.locator('#todos-fetched')).toHaveText('Todos fetched: 5');

const [serverTx, pageloadTx] = await Promise.all([serverTxPromise, pageloadTxPromise]);

expect(serverTx.contexts?.trace?.trace_id).toBeTruthy();
expect(pageloadTx.contexts?.trace?.trace_id).toBe(serverTx.contexts?.trace?.trace_id);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { expect, test } from '@playwright/test';
import { getSpanOp, waitForStreamedSpan } from '@sentry-internal/test-utils';

// The pageload should connect to the live serving request even though the shell is prerendered
// (trace context can only travel in the dynamic/resumed part of the response, never in cacheable
// HTML). The inverse assertion in cacheComponents.spec.ts ("Prerendered shell does not stitch
// the pageload onto a stale trace") documents today's un-connectedness.
test('connects the pageload trace to the live serving request', async ({ page }) => {
test.fail();

const serverSpanPromise = waitForStreamedSpan('nextjs-16-streaming-cacheComponents', span => {
return span.name === 'GET /pageload-tracing' && getSpanOp(span) === 'http.server' && span.is_segment;
});

const pageloadSpanPromise = waitForStreamedSpan('nextjs-16-streaming-cacheComponents', span => {
return span.name === '/pageload-tracing' && getSpanOp(span) === 'pageload' && span.is_segment;
});

await page.goto('/pageload-tracing');

await expect(page.locator('#todos-fetched')).toHaveText('Todos fetched: 5');

const [serverSpan, pageloadSpan] = await Promise.all([serverSpanPromise, pageloadSpanPromise]);

expect(serverSpan.trace_id).toBeTruthy();
expect(pageloadSpan.trace_id).toBe(serverSpan.trace_id);
});
Loading