@@ -74,8 +74,9 @@ 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
- const client = init ( options ) ;
79
+ const client = init ( { ... options , ctx : context } ) ;
79
80
isolationScope . setClient ( client ) ;
80
81
81
82
addCloudResourceContext ( isolationScope ) ;
@@ -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
- context . waitUntil ( flush ( 2000 ) ) ;
103
+ waitUntil ( flush ( 2000 ) ) ;
103
104
}
104
105
} ,
105
106
) ;
@@ -116,8 +117,9 @@ 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
- const client = init ( options ) ;
122
+ const client = init ( { ... options , ctx : context } ) ;
121
123
isolationScope . setClient ( client ) ;
122
124
123
125
addCloudResourceContext ( isolationScope ) ;
@@ -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
- context . waitUntil ( flush ( 2000 ) ) ;
144
+ waitUntil ( flush ( 2000 ) ) ;
143
145
}
144
146
} ,
145
147
) ;
@@ -157,8 +159,9 @@ 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
- const client = init ( options ) ;
164
+ const client = init ( { ... options , ctx : context } ) ;
162
165
isolationScope . setClient ( client ) ;
163
166
164
167
addCloudResourceContext ( isolationScope ) ;
@@ -185,7 +188,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
185
188
captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
186
189
throw e ;
187
190
} finally {
188
- context . waitUntil ( flush ( 2000 ) ) ;
191
+ waitUntil ( flush ( 2000 ) ) ;
189
192
}
190
193
} ,
191
194
) ;
@@ -204,7 +207,9 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
204
207
return withIsolationScope ( async isolationScope => {
205
208
const options = getFinalOptions ( optionsCallback ( env ) , env ) ;
206
209
207
- const client = init ( options ) ;
210
+ const waitUntil = context . waitUntil . bind ( context ) ;
211
+
212
+ const client = init ( { ...options , ctx : context } ) ;
208
213
isolationScope . setClient ( client ) ;
209
214
210
215
addCloudResourceContext ( isolationScope ) ;
@@ -215,7 +220,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
215
220
captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
216
221
throw e ;
217
222
} finally {
218
- context . waitUntil ( flush ( 2000 ) ) ;
223
+ waitUntil ( flush ( 2000 ) ) ;
219
224
}
220
225
} ) ;
221
226
} ,
0 commit comments