Skip to content

Commit 307d8ed

Browse files
mydeaclaude
andcommitted
test(remix): Tighten or relax error filters that misidentified envelopes
- capture-exception / capture-message routes execute on both SSR and client, so two error events were emitted; filter on platform === 'javascript' so we assert against the browser one. - The redirection-target loader and action-error tests asserted event.transaction, but the SDK does not reliably set that field on captured error events (integration tests never asserted it). Drop the transaction filter and match on the mechanism + node platform instead. - The throw-redirect server test filtered too narrowly on a specific transaction name, risking a false-pass; widen to any node-side error. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 589b4c6 commit 307d8ed

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

dev-packages/e2e-tests/test-applications/create-remix-app-express/tests/client-errors.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ test('Sends a client-side ErrorBoundary exception to Sentry', async ({ page }) =
2929
});
3030

3131
test('Reports a manually captured exception from a route', async ({ page }) => {
32+
// The route component runs on both server and browser, so two events are emitted.
33+
// We only care about the browser-side capture here.
3234
const errorPromise = waitForError('create-remix-app-express', errorEvent => {
33-
return errorEvent.exception?.values?.[0]?.value === 'Sentry Manually Captured Error';
35+
return (
36+
errorEvent.platform === 'javascript' &&
37+
errorEvent.exception?.values?.[0]?.value === 'Sentry Manually Captured Error'
38+
);
3439
});
3540

3641
await page.goto('/capture-exception');
@@ -51,7 +56,7 @@ test('Reports a manually captured exception from a route', async ({ page }) => {
5156

5257
test('Reports a manually captured message from a route', async ({ page }) => {
5358
const messagePromise = waitForError('create-remix-app-express', errorEvent => {
54-
return errorEvent.message === 'Sentry Manually Captured Message';
59+
return errorEvent.platform === 'javascript' && errorEvent.message === 'Sentry Manually Captured Message';
5560
});
5661

5762
await page.goto('/capture-message');

dev-packages/e2e-tests/test-applications/create-remix-app-express/tests/server-errors.test.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ test('Reports a thrown Response from a loader', async ({ page }) => {
5757
});
5858

5959
test('Reports an error in the redirection target loader', async ({ page }) => {
60+
// Same payload as the direct-loader-error test; serial execution + timestamp
61+
// gating in the proxy ensures this listener only matches the event emitted
62+
// for this test.
6063
const errorPromise = waitForError('create-remix-app-express', errorEvent => {
6164
return (
65+
errorEvent.platform === 'node' &&
6266
errorEvent.exception?.values?.[0]?.value === 'Unexpected Server Error' &&
63-
errorEvent.transaction === 'GET loader-json-response/:id'
67+
errorEvent.exception?.values?.[0]?.mechanism?.data?.function === 'remix.server.handleError'
6468
);
6569
});
6670

@@ -77,8 +81,10 @@ test('Reports an error thrown from an action', async ({ request }) => {
7781
});
7882
const errorPromise = waitForError('create-remix-app-express', errorEvent => {
7983
return (
84+
errorEvent.platform === 'node' &&
85+
errorEvent.request?.method === 'POST' &&
8086
errorEvent.exception?.values?.[0]?.value === 'Unexpected Server Error' &&
81-
errorEvent.transaction === 'POST action-json-response/:id'
87+
errorEvent.exception?.values?.[0]?.mechanism?.data?.function === 'remix.server.handleError'
8288
);
8389
});
8490

@@ -91,9 +97,7 @@ test('Reports an error thrown from an action', async ({ request }) => {
9197
expect(errorEvent.exception?.values?.[0]?.mechanism).toMatchObject({
9298
handled: false,
9399
type: 'auto.function.remix.server',
94-
data: { function: 'remix.server.handleError' },
95100
});
96-
expect(errorEvent.request?.method).toBe('POST');
97101
});
98102

99103
test('Reports a thrown json() error response with statusText', async ({ request }) => {
@@ -198,11 +202,11 @@ test('Reports an SSR error and applies tags from wrapHandleErrorWithSentry', asy
198202
});
199203

200204
test('Does not report a thrown redirect response on the server', async ({ page }) => {
201-
let redirectErrorReceived = false;
205+
let serverErrorReceived = false;
202206

203207
const errorPromise = waitForError('create-remix-app-express', errorEvent => {
204-
if (errorEvent.transaction === 'GET throw-redirect') {
205-
redirectErrorReceived = true;
208+
if (errorEvent.platform === 'node') {
209+
serverErrorReceived = true;
206210
return true;
207211
}
208212
return false;
@@ -212,5 +216,5 @@ test('Does not report a thrown redirect response on the server', async ({ page }
212216

213217
await Promise.race([errorPromise, new Promise(resolve => setTimeout(resolve, 3000))]);
214218

215-
expect(redirectErrorReceived).toBe(false);
219+
expect(serverErrorReceived).toBe(false);
216220
});

0 commit comments

Comments
 (0)