File tree Expand file tree Collapse file tree 1 file changed +12
-14
lines changed
packages/astro/src/server Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,18 @@ async function instrumentRequest(
193
193
sendErrorToSentry ( e ) ;
194
194
throw e ;
195
195
} finally {
196
- vercelWaitUntil ( flushSafelyWithTimeout ( ) ) ;
196
+ vercelWaitUntil (
197
+ ( async ( ) => {
198
+ // Flushes pending Sentry events with a 2-second timeout and in a way that cannot create unhandled promise rejections.
199
+ try {
200
+ DEBUG_BUILD && logger . log ( 'Flushing events...' ) ;
201
+ await flush ( 2000 ) ;
202
+ DEBUG_BUILD && logger . log ( 'Done flushing events' ) ;
203
+ } catch ( e ) {
204
+ DEBUG_BUILD && logger . log ( 'Error while flushing events:\n' , e ) ;
205
+ }
206
+ } ) ( ) ,
207
+ ) ;
197
208
}
198
209
// TODO: flush if serverless (first extract function)
199
210
} ,
@@ -219,19 +230,6 @@ function addMetaTagToHead(htmlChunk: string): string {
219
230
return htmlChunk . replace ( '<head>' , content ) ;
220
231
}
221
232
222
- /**
223
- * Flushes pending Sentry events with a 2-second timeout and in a way that cannot create unhandled promise rejections.
224
- */
225
- export async function flushSafelyWithTimeout ( ) : Promise < void > {
226
- try {
227
- DEBUG_BUILD && logger . log ( 'Flushing events...' ) ;
228
- await flush ( 2000 ) ;
229
- DEBUG_BUILD && logger . log ( 'Done flushing events' ) ;
230
- } catch ( e ) {
231
- DEBUG_BUILD && logger . log ( 'Error while flushing events:\n' , e ) ;
232
- }
233
- }
234
-
235
233
/**
236
234
* Interpolates the route from the URL and the passed params.
237
235
* Best we can do to get a route name instead of a raw URL.
You can’t perform that action at this time.
0 commit comments