Skip to content

Commit b9dd738

Browse files
committed
fix(sveltekit): Avoid capturing redirect() calls as errors in CloudFlare
1 parent 77c3ddf commit b9dd738

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/sveltekit/src/worker/cloudflare.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export function initCloudflareSentryHandle(options: CloudflareOptions): Handle {
3737
request: event.request as Request<unknown, IncomingRequestCfProperties<unknown>>,
3838
// @ts-expect-error This will exist in Cloudflare
3939
context: event.platform.context,
40+
// We don't want to capture errors here, as we want to capture them in the `sentryHandle` handler
41+
// where we can distinguish between redirects and actual errors.
42+
captureErrors: false,
4043
},
4144
() => resolve(event),
4245
);

packages/sveltekit/test/worker/cloudflare.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('initCloudflareSentryHandle', () => {
4545

4646
expect(SentryCloudflare.wrapRequestHandler).toHaveBeenCalledTimes(1);
4747
expect(SentryCloudflare.wrapRequestHandler).toHaveBeenCalledWith(
48-
{ options: expect.objectContaining({ dsn: options.dsn }), request, context },
48+
{ options: expect.objectContaining({ dsn: options.dsn }), request, context, captureErrors: false },
4949
expect.any(Function),
5050
);
5151

0 commit comments

Comments
 (0)