Skip to content

Commit f8f196e

Browse files
authored
feat(cloudflare): Re-export httpServerIntegration from /request (#24614)
Idea brought up here: Shopify/hydrogen#3828 (comment) Wouldn't harm if we re-export this into `/request`
1 parent 6c445ad commit f8f196e

4 files changed

Lines changed: 33 additions & 1 deletion

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export async function action() {
2+
throw new Error('Action Error');
3+
}
4+
5+
export default function ActionError() {
6+
return (
7+
<div>
8+
<h1>Action Error</h1>
9+
</div>
10+
);
11+
}

‎dev-packages/e2e-tests/test-applications/hydrogen-react-router-7/server.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import { type AppLoadContext, createRequestHandler, getStorefrontHeaders } from '@shopify/remix-oxygen';
1010
import { CART_QUERY_FRAGMENT } from '~/lib/fragments';
1111
import { AppSession } from '~/lib/session';
12-
import { wrapRequestHandler } from '@sentry/cloudflare/request';
12+
import { httpServerIntegration, wrapRequestHandler } from '@sentry/cloudflare/request';
1313
// Virtual entry point for the app
1414
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1515
// @ts-expect-error
@@ -38,6 +38,7 @@ export default {
3838
dsn: 'https://public@dsn.ingest.sentry.io/1337',
3939
tracesSampleRate: 1.0,
4040
tunnel: `http://localhost:3031/`, // proxy server
41+
integrations: [httpServerIntegration({ maxRequestBodySize: 'small' })],
4142
},
4243
// Need to cast to any because this is not on cloudflare
4344
request: request as any,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { expect, test } from '@playwright/test';
2+
import { waitForError } from '@sentry-internal/test-utils';
3+
4+
test('Applies the options of `httpServerIntegration` imported from `@sentry/cloudflare/request`', async ({
5+
request,
6+
}) => {
7+
const errorPromise = waitForError('hydrogen-react-router-7', errorEvent => {
8+
return errorEvent.exception?.values?.[0]?.value === 'Action Error';
9+
});
10+
11+
const body = JSON.stringify({ payload: 'x'.repeat(4_000) });
12+
await request.post('/action-error', { data: body, headers: { 'content-type': 'application/json' } });
13+
14+
const errorEvent = await errorPromise;
15+
16+
// `maxRequestBodySize: 'small'` truncates at 1,000 bytes, the default (`'medium'`) would keep the full body.
17+
expect(errorEvent.request?.data).toBe(`${body.slice(0, 997)}...`);
18+
});

‎packages/cloudflare/src/request.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ export function wrapRequestHandler(
2020
): Promise<Response> {
2121
return wrapRequestHandlerWithInit(wrapperOptions, handler, initBaseSdk);
2222
}
23+
24+
export { httpServerIntegration } from './integrations/httpServer';

0 commit comments

Comments
 (0)