Skip to content

fix(nextjs): Update stackframe calls for next v15.5 #17156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 24, 2025
Merged
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
@@ -1,35 +1,30 @@
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';

test.describe('dev mode error symbolification', () => {
if (process.env.TEST_ENV !== 'development') {
test.skip('should be skipped for non-dev mode', () => {});
return;
}
test('should have symbolicated dev errors', async ({ page }) => {
test.skip(process.env.TEST_ENV !== 'development', 'should be skipped for non-dev mode');

test('should have symbolicated dev errors', async ({ page }) => {
await page.goto('/');
await page.goto('/');

const errorEventPromise = waitForError('nextjs-app-dir', errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Click Error';
});
const errorEventPromise = waitForError('nextjs-app-dir', errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Click Error';
});

await page.getByText('Throw error').click();
await page.getByText('Throw error').click();

const errorEvent = await errorEventPromise;
const errorEventFrames = errorEvent.exception?.values?.[0]?.stacktrace?.frames;
const errorEvent = await errorEventPromise;
const errorEventFrames = errorEvent.exception?.values?.[0]?.stacktrace?.frames;

expect(errorEventFrames?.[errorEventFrames?.length - 1]).toEqual(
expect.objectContaining({
function: 'onClick',
filename: 'components/client-error-debug-tools.tsx',
lineno: 54,
colno: expect.any(Number),
in_app: true,
pre_context: [' <button', ' onClick={() => {'],
context_line: " throw new Error('Click Error');",
post_context: [' }}', ' >', ' Throw error'],
}),
);
});
expect(errorEventFrames?.[errorEventFrames?.length - 1]).toEqual(
expect.objectContaining({
function: 'onClick',
filename: 'components/client-error-debug-tools.tsx',
lineno: 54,
colno: expect.any(Number),
in_app: true,
pre_context: [' <button', ' onClick={() => {'],
context_line: " throw new Error('Click Error');",
post_context: [' }}', ' >', ' Throw error'],
}),
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function devErrorSymbolicationEventProcessor(event: Event, hint: Ev

let resolvedFrames: ({
originalCodeFrame: string | null;
originalStackFrame: StackFrame | null;
originalStackFrame: (StackFrame & { line1?: number; column1?: number }) | null;
} | null)[];

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down Expand Up @@ -84,8 +84,9 @@ export async function devErrorSymbolicationEventProcessor(event: Event, hint: Ev
post_context: postContextLines,
function: resolvedFrame.originalStackFrame.methodName,
filename: resolvedFrame.originalStackFrame.file || undefined,
lineno: resolvedFrame.originalStackFrame.lineNumber || undefined,
colno: resolvedFrame.originalStackFrame.column || undefined,
lineno:
resolvedFrame.originalStackFrame.lineNumber || resolvedFrame.originalStackFrame.line1 || undefined,
colno: resolvedFrame.originalStackFrame.column || resolvedFrame.originalStackFrame.column1 || undefined,
};
},
);
Expand Down Expand Up @@ -175,6 +176,8 @@ async function resolveStackFrames(
arguments: [],
lineNumber: frame.lineNumber ?? 0,
column: frame.column ?? 0,
line1: frame.lineNumber ?? 0,
column1: frame.column ?? 0,
};
}),
isServer: false,
Expand Down
Loading