Skip to content

Commit

Permalink
feat(remix): Mark errors caught from Remix instrumentation as unhandl…
Browse files Browse the repository at this point in the history
…ed (#8894)

Mark errors caught from remix instrumentation as unhandled:
* `captureRemixErrorBoundaryError` 
* `captureRemixServerException`

For more details see #8890, #6073
  • Loading branch information
Lms24 committed Sep 4, 2023
1 parent b102817 commit 39401f0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/remix/src/client/errors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function captureRemixErrorBoundaryError(error: unknown): void {
scope.addEventProcessor(event => {
addExceptionMechanism(event, {
type: 'instrument',
handled: true,
handled: false,
data: eventData,
});
return event;
Expand Down
2 changes: 1 addition & 1 deletion packages/remix/src/utils/instrumentServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export async function captureRemixServerException(err: unknown, name: string, re
scope.addEventProcessor(event => {
addExceptionMechanism(event, {
type: 'instrument',
handled: true,
handled: false,
data: {
function: name,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('should capture React component errors.', async ({ page }) => {

const [pageloadEnvelope, errorEnvelope] = envelopes;

expect(pageloadEnvelope.contexts?.trace.op).toBe('pageload');
expect(pageloadEnvelope.contexts?.trace?.op).toBe('pageload');
expect(pageloadEnvelope.tags?.['routing.instrumentation']).toBe('remix-router');
expect(pageloadEnvelope.type).toBe('transaction');
expect(pageloadEnvelope.transaction).toBe(
Expand All @@ -27,14 +27,17 @@ test('should capture React component errors.', async ({ page }) => {
type: 'React ErrorBoundary Error',
value: 'Sentry React Component Error',
stacktrace: { frames: expect.any(Array) },
mechanism: { type: 'chained', handled: false },
},
]
: []),
{
type: 'Error',
value: 'Sentry React Component Error',
stacktrace: { frames: expect.any(Array) },
mechanism: { type: useV2 ? 'instrument' : 'generic', handled: true },
// In v2 this error will be marked unhandled, in v1 its handled because of LinkedErrors
// This should be fine though because the error boundary's error is marked unhandled
mechanism: { type: useV2 ? 'instrument' : 'generic', handled: !useV2 },
},
]);
});
12 changes: 6 additions & 6 deletions packages/remix/test/integration/test/server/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
data: {
function: useV2 ? 'remix.server' : 'action',
},
handled: true,
handled: false,
type: 'instrument',
},
},
Expand Down Expand Up @@ -203,7 +203,7 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
data: {
function: useV2 ? 'remix.server' : 'loader',
},
handled: true,
handled: false,
type: 'instrument',
},
},
Expand Down Expand Up @@ -256,7 +256,7 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
data: {
function: useV2 ? 'ErrorResponse' : 'action',
},
handled: true,
handled: false,
type: 'instrument',
},
},
Expand Down Expand Up @@ -311,7 +311,7 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
data: {
function: useV2 ? 'ErrorResponse' : 'action',
},
handled: true,
handled: false,
type: 'instrument',
},
},
Expand Down Expand Up @@ -364,7 +364,7 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
data: {
function: useV2 ? 'ErrorResponse' : 'action',
},
handled: true,
handled: false,
type: 'instrument',
},
},
Expand Down Expand Up @@ -419,7 +419,7 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
data: {
function: useV2 ? 'ErrorResponse' : 'action',
},
handled: true,
handled: false,
type: 'instrument',
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/remix/test/integration/test/server/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
data: {
function: useV2 ? 'remix.server' : 'loader',
},
handled: true,
handled: false,
type: 'instrument',
},
},
Expand Down Expand Up @@ -140,7 +140,7 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
data: {
function: useV2 ? 'remix.server' : 'loader',
},
handled: true,
handled: false,
type: 'instrument',
},
},
Expand Down

0 comments on commit 39401f0

Please sign in to comment.