From ab66a0b09ff0f4bc3769e311fa172c2ed6f05034 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Thu, 31 Jul 2025 11:38:20 +0200 Subject: [PATCH 1/3] ref(solid): Add `mechanism` to error captured by `withSentryErrorBoundary` --- packages/solid/src/errorboundary.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/solid/src/errorboundary.ts b/packages/solid/src/errorboundary.ts index df75f9da80f9..68b235321412 100644 --- a/packages/solid/src/errorboundary.ts +++ b/packages/solid/src/errorboundary.ts @@ -17,7 +17,12 @@ export function withSentryErrorBoundary(ErrorBoundary: Component void): JSX.Element => { - captureException(error); + captureException(error, { + mechanism: { + handled: true, // handled because user has to provide a fallback + type: 'solid.error-boundary', + }, + }); const f = local.fallback; return typeof f === 'function' ? f(error, reset) : f; From ba1c69263fd2e79deeb213cd260fed665fb968ce Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 12 Sep 2025 10:38:17 +0200 Subject: [PATCH 2/3] adjust tests --- .../tests/errorboundary.test.ts | 6 +++--- .../solid/tests/errorboundary.test.ts | 6 +++--- packages/solid/src/errorboundary.ts | 2 +- packages/solid/test/errorboundary.test.tsx | 21 ++++++++++++++++--- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/solid-solidrouter/tests/errorboundary.test.ts b/dev-packages/e2e-tests/test-applications/solid-solidrouter/tests/errorboundary.test.ts index 287642424850..14396feb2334 100644 --- a/dev-packages/e2e-tests/test-applications/solid-solidrouter/tests/errorboundary.test.ts +++ b/dev-packages/e2e-tests/test-applications/solid-solidrouter/tests/errorboundary.test.ts @@ -15,7 +15,7 @@ test('captures an exception', async ({ page }) => { type: 'ReferenceError', value: 'NonExistentComponent is not defined', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -39,7 +39,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'ReferenceError', value: 'NonExistentComponent is not defined', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -64,7 +64,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'ReferenceError', value: 'NonExistentComponent is not defined', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, diff --git a/dev-packages/e2e-tests/test-applications/solid/tests/errorboundary.test.ts b/dev-packages/e2e-tests/test-applications/solid/tests/errorboundary.test.ts index d192ed9cfcfd..896426e1765c 100644 --- a/dev-packages/e2e-tests/test-applications/solid/tests/errorboundary.test.ts +++ b/dev-packages/e2e-tests/test-applications/solid/tests/errorboundary.test.ts @@ -22,7 +22,7 @@ test('captures an exception', async ({ page }) => { type: 'Error', value: 'Error 1 thrown from Sentry ErrorBoundary in Solid E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -53,7 +53,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'Error', value: 'Error 1 thrown from Sentry ErrorBoundary in Solid E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -82,7 +82,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'Error', value: 'Error 2 thrown from Sentry ErrorBoundary in Solid E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, diff --git a/packages/solid/src/errorboundary.ts b/packages/solid/src/errorboundary.ts index 68b235321412..aaf99c3f23b2 100644 --- a/packages/solid/src/errorboundary.ts +++ b/packages/solid/src/errorboundary.ts @@ -20,7 +20,7 @@ export function withSentryErrorBoundary(ErrorBoundary: Component { )); expect(mockCaptureException).toHaveBeenCalledTimes(1); - expect(mockCaptureException).toHaveBeenLastCalledWith(new ReferenceError('NonExistentComponent is not defined')); + expect(mockCaptureException).toHaveBeenLastCalledWith(new ReferenceError('NonExistentComponent is not defined'), { + mechanism: { + handled: true, + type: 'auto.function.solid.error_boundary', + }, + }); }); it('renders the fallback component', async () => { @@ -89,13 +94,23 @@ describe('withSentryErrorBoundary', () => { )); expect(mockCaptureException).toHaveBeenCalledTimes(1); - expect(mockCaptureException).toHaveBeenNthCalledWith(1, new ReferenceError('NonExistentComponent is not defined')); + expect(mockCaptureException).toHaveBeenNthCalledWith(1, new ReferenceError('NonExistentComponent is not defined'), { + mechanism: { + handled: true, + type: 'auto.function.solid.error_boundary', + }, + }); const button = await findByRole('button'); await user.click(button); expect(mockCaptureException).toHaveBeenCalledTimes(2); - expect(mockCaptureException).toHaveBeenNthCalledWith(2, new ReferenceError('NonExistentComponent is not defined')); + expect(mockCaptureException).toHaveBeenNthCalledWith(2, new ReferenceError('NonExistentComponent is not defined'), { + mechanism: { + handled: true, + type: 'auto.function.solid.error_boundary', + }, + }); }); it('renders children when there is no error', async () => { From f611aa4eff6cb346419e94c0a7f4c74a079250de Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 12 Sep 2025 11:19:02 +0200 Subject: [PATCH 3/3] adjust solidstart tests --- .../tests/errorboundary.test.ts | 6 +++--- .../tests/errorboundary.test.ts | 6 +++--- .../tests/errorboundary.test.ts | 6 +++--- .../solidstart/tests/errorboundary.test.ts | 6 +++--- .../test/client/errorboundary.test.tsx | 21 ++++++++++++++++--- .../test/server/errorboundary.test.tsx | 21 ++++++++++++++++--- 6 files changed, 48 insertions(+), 18 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/solidstart-dynamic-import/tests/errorboundary.test.ts b/dev-packages/e2e-tests/test-applications/solidstart-dynamic-import/tests/errorboundary.test.ts index 599b5c121455..63b46a5870ec 100644 --- a/dev-packages/e2e-tests/test-applications/solidstart-dynamic-import/tests/errorboundary.test.ts +++ b/dev-packages/e2e-tests/test-applications/solidstart-dynamic-import/tests/errorboundary.test.ts @@ -23,7 +23,7 @@ test('captures an exception', async ({ page }) => { type: 'Error', value: 'Error 1 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -53,7 +53,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'Error', value: 'Error 1 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -81,7 +81,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'Error', value: 'Error 2 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, diff --git a/dev-packages/e2e-tests/test-applications/solidstart-spa/tests/errorboundary.test.ts b/dev-packages/e2e-tests/test-applications/solidstart-spa/tests/errorboundary.test.ts index 692e19f54393..4cf6eccd4b71 100644 --- a/dev-packages/e2e-tests/test-applications/solidstart-spa/tests/errorboundary.test.ts +++ b/dev-packages/e2e-tests/test-applications/solidstart-spa/tests/errorboundary.test.ts @@ -21,7 +21,7 @@ test('captures an exception', async ({ page }) => { type: 'Error', value: 'Error 1 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -51,7 +51,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'Error', value: 'Error 1 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -79,7 +79,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'Error', value: 'Error 2 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, diff --git a/dev-packages/e2e-tests/test-applications/solidstart-top-level-import/tests/errorboundary.test.ts b/dev-packages/e2e-tests/test-applications/solidstart-top-level-import/tests/errorboundary.test.ts index 49f50f882b50..a362fc76de84 100644 --- a/dev-packages/e2e-tests/test-applications/solidstart-top-level-import/tests/errorboundary.test.ts +++ b/dev-packages/e2e-tests/test-applications/solidstart-top-level-import/tests/errorboundary.test.ts @@ -21,7 +21,7 @@ test('captures an exception', async ({ page }) => { type: 'Error', value: 'Error 1 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -51,7 +51,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'Error', value: 'Error 1 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -79,7 +79,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'Error', value: 'Error 2 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, diff --git a/dev-packages/e2e-tests/test-applications/solidstart/tests/errorboundary.test.ts b/dev-packages/e2e-tests/test-applications/solidstart/tests/errorboundary.test.ts index b709760aab94..9b169d6abda4 100644 --- a/dev-packages/e2e-tests/test-applications/solidstart/tests/errorboundary.test.ts +++ b/dev-packages/e2e-tests/test-applications/solidstart/tests/errorboundary.test.ts @@ -21,7 +21,7 @@ test('captures an exception', async ({ page }) => { type: 'Error', value: 'Error 1 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -51,7 +51,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'Error', value: 'Error 1 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, @@ -79,7 +79,7 @@ test('captures a second exception after resetting the boundary', async ({ page } type: 'Error', value: 'Error 2 thrown from Sentry ErrorBoundary in Solid Start E2E test app', mechanism: { - type: 'generic', + type: 'auto.function.solid.error_boundary', handled: true, }, }, diff --git a/packages/solidstart/test/client/errorboundary.test.tsx b/packages/solidstart/test/client/errorboundary.test.tsx index f1fc2c943ac1..099ab1f4bf2a 100644 --- a/packages/solidstart/test/client/errorboundary.test.tsx +++ b/packages/solidstart/test/client/errorboundary.test.tsx @@ -49,7 +49,12 @@ describe('withSentryErrorBoundary', () => { )); expect(mockCaptureException).toHaveBeenCalledTimes(1); - expect(mockCaptureException).toHaveBeenLastCalledWith(new ReferenceError('NonExistentComponent is not defined')); + expect(mockCaptureException).toHaveBeenLastCalledWith(new ReferenceError('NonExistentComponent is not defined'), { + mechanism: { + handled: true, + type: 'auto.function.solid.error_boundary', + }, + }); }); it('renders the fallback component', async () => { @@ -89,13 +94,23 @@ describe('withSentryErrorBoundary', () => { )); expect(mockCaptureException).toHaveBeenCalledTimes(1); - expect(mockCaptureException).toHaveBeenNthCalledWith(1, new ReferenceError('NonExistentComponent is not defined')); + expect(mockCaptureException).toHaveBeenNthCalledWith(1, new ReferenceError('NonExistentComponent is not defined'), { + mechanism: { + handled: true, + type: 'auto.function.solid.error_boundary', + }, + }); const button = await findByRole('button'); await user.click(button); expect(mockCaptureException).toHaveBeenCalledTimes(2); - expect(mockCaptureException).toHaveBeenNthCalledWith(2, new ReferenceError('NonExistentComponent is not defined')); + expect(mockCaptureException).toHaveBeenNthCalledWith(2, new ReferenceError('NonExistentComponent is not defined'), { + mechanism: { + handled: true, + type: 'auto.function.solid.error_boundary', + }, + }); }); it('renders children when there is no error', async () => { diff --git a/packages/solidstart/test/server/errorboundary.test.tsx b/packages/solidstart/test/server/errorboundary.test.tsx index afa2d44e98d7..3ed39bbfea13 100644 --- a/packages/solidstart/test/server/errorboundary.test.tsx +++ b/packages/solidstart/test/server/errorboundary.test.tsx @@ -49,7 +49,12 @@ describe('withSentryErrorBoundary', () => { )); expect(mockCaptureException).toHaveBeenCalledTimes(1); - expect(mockCaptureException).toHaveBeenLastCalledWith(new ReferenceError('NonExistentComponent is not defined')); + expect(mockCaptureException).toHaveBeenLastCalledWith(new ReferenceError('NonExistentComponent is not defined'), { + mechanism: { + handled: true, + type: 'auto.function.solid.error_boundary', + }, + }); }); it('renders the fallback component', async () => { @@ -89,13 +94,23 @@ describe('withSentryErrorBoundary', () => { )); expect(mockCaptureException).toHaveBeenCalledTimes(1); - expect(mockCaptureException).toHaveBeenNthCalledWith(1, new ReferenceError('NonExistentComponent is not defined')); + expect(mockCaptureException).toHaveBeenNthCalledWith(1, new ReferenceError('NonExistentComponent is not defined'), { + mechanism: { + handled: true, + type: 'auto.function.solid.error_boundary', + }, + }); const button = await findByRole('button'); await user.click(button); expect(mockCaptureException).toHaveBeenCalledTimes(2); - expect(mockCaptureException).toHaveBeenNthCalledWith(2, new ReferenceError('NonExistentComponent is not defined')); + expect(mockCaptureException).toHaveBeenNthCalledWith(2, new ReferenceError('NonExistentComponent is not defined'), { + mechanism: { + handled: true, + type: 'auto.function.solid.error_boundary', + }, + }); }); it('renders children when there is no error', async () => {