Skip to content

Commit 54576cf

Browse files
authored
fix(v9/nextjs): Flush in route handlers (#17245)
backports #17223
1 parent 8a30f22 commit 54576cf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import {
1212
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
1313
setCapturedScopesOnSpan,
1414
setHttpStatus,
15+
vercelWaitUntil,
1516
winterCGHeadersToDict,
1617
withIsolationScope,
1718
withScope,
1819
} from '@sentry/core';
1920
import { isNotFoundNavigationError, isRedirectNavigationError } from './nextNavigationErrorUtils';
2021
import type { RouteHandlerContext } from './types';
22+
import { flushSafelyWithTimeout } from './utils/responseEnd';
2123
import { commonObjectToIsolationScope } from './utils/tracingUtils';
2224

2325
/**
@@ -92,6 +94,9 @@ export function wrapRouteHandlerWithSentry<F extends (...args: any[]) => any>(
9294
});
9395
}
9496
},
97+
() => {
98+
vercelWaitUntil(flushSafelyWithTimeout());
99+
},
95100
);
96101

97102
try {

0 commit comments

Comments
 (0)