Skip to content

Commit 8087a57

Browse files
committed
WIP: Handling uncaught errors in SolidStart
The SDK cannot currently deal with uncaught errors properly. Neither in routes nor in server actions as demonstrated by the two e2e tests in this PR.
1 parent 3e31bdc commit 8087a57

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

dev-packages/e2e-tests/test-applications/solidstart/src/routes/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ export default function Home() {
2525
<li>
2626
<A href="/back-navigation">Test back navigation</A>
2727
</li>
28+
<li>
29+
<A href="/uncaught-route-error">Test uncaught errors in routes</A>
30+
</li>
31+
<li>
32+
<A href="/server-error-without-instrumentation">Test uncaught errors in server action without instrumentation wrapper</A>
33+
</li>
2834
</ul>
2935
</>
3036
);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function UncaughtErrorPage() {
2+
throw new Error('Uncaught error thrown in UncaughtErrorPage route from Solid Start E2E test app');
3+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { createAsync } from '@solidjs/router';
2+
const getPrefecture = async () => {
3+
'use server';
4+
throw new Error('Error thrown from Solid Start E2E test app server route without instrumentation wrapper');
5+
6+
return { prefecture: 'Kanagawa' };
7+
};
8+
9+
export default function UncaughtServerErrorWithoutInstrumentationPage() {
10+
const data = createAsync(() => getPrefecture());
11+
12+
return <div>Prefecture: {data()?.prefecture}</div>;
13+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { expect, test } from '@playwright/test';
2+
import { waitForError } from '@sentry-internal/test-utils';
3+
4+
test.describe('server-side errors', () => {
5+
test('captures server action error', async ({ page }) => {
6+
const errorEventPromise = waitForError('solidstart', errorEvent => {
7+
return errorEvent?.exception?.values?.[0]?.value === 'Error thrown from Solid Start E2E test app server route without instrumentation wrapper';
8+
});
9+
10+
await page.goto(`/uncaught-server-error-without-instrumentation`);
11+
12+
const error = await errorEventPromise;
13+
14+
expect(error).toMatchObject({
15+
exception: {
16+
values: [
17+
{
18+
type: 'Error',
19+
value: 'Error thrown from Solid Start E2E test app server route without instrumentation wrapper',
20+
mechanism: {
21+
type: 'solidstart',
22+
handled: false,
23+
},
24+
},
25+
],
26+
},
27+
transaction: 'GET /uncaught-server-error-without-instrumentation',
28+
});
29+
});
30+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { expect, test } from '@playwright/test';
2+
import { waitForError } from '@sentry-internal/test-utils';
3+
4+
test.describe('client-side errors', () => {
5+
test('captures error thrown on click', async ({ page }) => {
6+
const errorPromise = waitForError('solidstart', async errorEvent => {
7+
return errorEvent?.exception?.values?.[0]?.value === 'Uncaught error thrown in UncaughtErrorPage route from Solid Start E2E test app';
8+
});
9+
10+
await page.goto(`/uncaught-route-error`);
11+
const error = await errorPromise;
12+
13+
expect(error).toMatchObject({
14+
exception: {
15+
values: [
16+
{
17+
type: 'Error',
18+
value: 'Uncaught error thrown in UncaughtErrorPage route from Solid Start E2E test app',
19+
mechanism: {
20+
handled: false,
21+
},
22+
},
23+
],
24+
},
25+
transaction: '/uncaught-route-error',
26+
});
27+
expect(error.transaction).toEqual('/uncaught-route-error');
28+
});
29+
});

0 commit comments

Comments
 (0)