Skip to content
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

WIP: Handling uncaught errors in SolidStart #15245

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
Expand Up @@ -25,6 +25,12 @@ export default function Home() {
<li>
<A href="/back-navigation">Test back navigation</A>
</li>
<li>
<A href="/uncaught-route-error">Test uncaught errors in routes</A>
</li>
<li>
<A href="/server-error-without-instrumentation">Test uncaught errors in server action without instrumentation wrapper</A>
</li>
</ul>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function UncaughtErrorPage() {
throw new Error('Uncaught error thrown in UncaughtErrorPage route from Solid Start E2E test app');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createAsync } from '@solidjs/router';
const getPrefecture = async () => {
'use server';
throw new Error('Error thrown from Solid Start E2E test app server route without instrumentation wrapper');

return { prefecture: 'Kanagawa' };
};

export default function UncaughtServerErrorWithoutInstrumentationPage() {
const data = createAsync(() => getPrefecture());

return <div>Prefecture: {data()?.prefecture}</div>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';

test.describe('server-side errors', () => {
test('captures server action error', async ({ page }) => {
const errorEventPromise = waitForError('solidstart', errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Error thrown from Solid Start E2E test app server route without instrumentation wrapper';
});

await page.goto(`/uncaught-server-error-without-instrumentation`);

const error = await errorEventPromise;

expect(error).toMatchObject({
exception: {
values: [
{
type: 'Error',
value: 'Error thrown from Solid Start E2E test app server route without instrumentation wrapper',
mechanism: {
type: 'solidstart',
handled: false,
},
},
],
},
transaction: 'GET /uncaught-server-error-without-instrumentation',
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect, test } from '@playwright/test';
import { waitForError } from '@sentry-internal/test-utils';

test.describe('client-side errors', () => {
test('captures error thrown on click', async ({ page }) => {
const errorPromise = waitForError('solidstart', async errorEvent => {
return errorEvent?.exception?.values?.[0]?.value === 'Uncaught error thrown in UncaughtErrorPage route from Solid Start E2E test app';
});

await page.goto(`/uncaught-route-error`);
const error = await errorPromise;

expect(error).toMatchObject({
exception: {
values: [
{
type: 'Error',
value: 'Uncaught error thrown in UncaughtErrorPage route from Solid Start E2E test app',
mechanism: {
handled: false,
},
},
],
},
transaction: '/uncaught-route-error',
});
expect(error.transaction).toEqual('/uncaught-route-error');
});
});
Loading