1
1
import {
2
2
captureException ,
3
- flushIfServerless ,
3
+ flush ,
4
4
SEMANTIC_ATTRIBUTE_SENTRY_OP ,
5
5
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ,
6
6
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ,
@@ -74,6 +74,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
74
74
const [ event , env , context ] = args ;
75
75
return withIsolationScope ( isolationScope => {
76
76
const options = getFinalOptions ( optionsCallback ( env ) , env ) ;
77
+ const waitUntil = context . waitUntil . bind ( context ) ;
77
78
78
79
const client = init ( { ...options , ctx : context } ) ;
79
80
isolationScope . setClient ( client ) ;
@@ -99,7 +100,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
99
100
captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
100
101
throw e ;
101
102
} finally {
102
- await flushIfServerless ( { cloudflareCtx : context } ) ;
103
+ waitUntil ( flush ( 2000 ) ) ;
103
104
}
104
105
} ,
105
106
) ;
@@ -116,6 +117,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
116
117
const [ emailMessage , env , context ] = args ;
117
118
return withIsolationScope ( isolationScope => {
118
119
const options = getFinalOptions ( optionsCallback ( env ) , env ) ;
120
+ const waitUntil = context . waitUntil . bind ( context ) ;
119
121
120
122
const client = init ( { ...options , ctx : context } ) ;
121
123
isolationScope . setClient ( client ) ;
@@ -139,7 +141,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
139
141
captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
140
142
throw e ;
141
143
} finally {
142
- await flushIfServerless ( { cloudflareCtx : context } ) ;
144
+ waitUntil ( flush ( 2000 ) ) ;
143
145
}
144
146
} ,
145
147
) ;
@@ -157,6 +159,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
157
159
158
160
return withIsolationScope ( isolationScope => {
159
161
const options = getFinalOptions ( optionsCallback ( env ) , env ) ;
162
+ const waitUntil = context . waitUntil . bind ( context ) ;
160
163
161
164
const client = init ( { ...options , ctx : context } ) ;
162
165
isolationScope . setClient ( client ) ;
@@ -188,7 +191,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
188
191
captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
189
192
throw e ;
190
193
} finally {
191
- await flushIfServerless ( { cloudflareCtx : context } ) ;
194
+ waitUntil ( flush ( 2000 ) ) ;
192
195
}
193
196
} ,
194
197
) ;
@@ -207,6 +210,8 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
207
210
return withIsolationScope ( async isolationScope => {
208
211
const options = getFinalOptions ( optionsCallback ( env ) , env ) ;
209
212
213
+ const waitUntil = context . waitUntil . bind ( context ) ;
214
+
210
215
const client = init ( { ...options , ctx : context } ) ;
211
216
isolationScope . setClient ( client ) ;
212
217
@@ -218,7 +223,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
218
223
captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
219
224
throw e ;
220
225
} finally {
221
- await flushIfServerless ( { cloudflareCtx : context } ) ;
226
+ waitUntil ( flush ( 2000 ) ) ;
222
227
}
223
228
} ) ;
224
229
} ,
0 commit comments