From fecefb9bebba6bd68c336121066d22b76991f712 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Thu, 23 Jan 2025 12:43:23 +0000 Subject: [PATCH 1/2] fix(nextjs): Flush with `waitUntil` in `captureRequestError` --- packages/nextjs/src/common/captureRequestError.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/nextjs/src/common/captureRequestError.ts b/packages/nextjs/src/common/captureRequestError.ts index 26fdaab4953b..38aefdbb506d 100644 --- a/packages/nextjs/src/common/captureRequestError.ts +++ b/packages/nextjs/src/common/captureRequestError.ts @@ -1,5 +1,6 @@ -import type { RequestEventData } from '@sentry/core'; +import { RequestEventData, vercelWaitUntil } from '@sentry/core'; import { captureException, headersToDict, withScope } from '@sentry/core'; +import { flushSafelyWithTimeout } from './utils/responseEnd'; type RequestInfo = { path: string; @@ -39,5 +40,7 @@ export function captureRequestError(error: unknown, request: RequestInfo, errorC handled: false, }, }); + + vercelWaitUntil(flushSafelyWithTimeout()); }); } From 84b2bdb5af279b7b705ffbe8a10b86fb62d619bd Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Thu, 23 Jan 2025 13:55:44 +0000 Subject: [PATCH 2/2] . --- packages/nextjs/src/common/captureRequestError.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/nextjs/src/common/captureRequestError.ts b/packages/nextjs/src/common/captureRequestError.ts index 38aefdbb506d..c872d70f8334 100644 --- a/packages/nextjs/src/common/captureRequestError.ts +++ b/packages/nextjs/src/common/captureRequestError.ts @@ -1,4 +1,5 @@ -import { RequestEventData, vercelWaitUntil } from '@sentry/core'; +import type { RequestEventData } from '@sentry/core'; +import { vercelWaitUntil } from '@sentry/core'; import { captureException, headersToDict, withScope } from '@sentry/core'; import { flushSafelyWithTimeout } from './utils/responseEnd';