@@ -74,8 +74,9 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
7474 const [ event , env , context ] = args ;
7575 return withIsolationScope ( isolationScope => {
7676 const options = getFinalOptions ( optionsCallback ( env ) , env ) ;
77+ const waitUntil = context . waitUntil . bind ( context ) ;
7778
78- const client = init ( options ) ;
79+ const client = init ( { ... options , ctx : context } ) ;
7980 isolationScope . setClient ( client ) ;
8081
8182 addCloudResourceContext ( isolationScope ) ;
@@ -99,7 +100,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
99100 captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
100101 throw e ;
101102 } finally {
102- context . waitUntil ( flush ( 2000 ) ) ;
103+ waitUntil ( flush ( 2000 ) ) ;
103104 }
104105 } ,
105106 ) ;
@@ -116,8 +117,9 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
116117 const [ emailMessage , env , context ] = args ;
117118 return withIsolationScope ( isolationScope => {
118119 const options = getFinalOptions ( optionsCallback ( env ) , env ) ;
120+ const waitUntil = context . waitUntil . bind ( context ) ;
119121
120- const client = init ( options ) ;
122+ const client = init ( { ... options , ctx : context } ) ;
121123 isolationScope . setClient ( client ) ;
122124
123125 addCloudResourceContext ( isolationScope ) ;
@@ -139,7 +141,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
139141 captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
140142 throw e ;
141143 } finally {
142- context . waitUntil ( flush ( 2000 ) ) ;
144+ waitUntil ( flush ( 2000 ) ) ;
143145 }
144146 } ,
145147 ) ;
@@ -157,8 +159,9 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
157159
158160 return withIsolationScope ( isolationScope => {
159161 const options = getFinalOptions ( optionsCallback ( env ) , env ) ;
162+ const waitUntil = context . waitUntil . bind ( context ) ;
160163
161- const client = init ( options ) ;
164+ const client = init ( { ... options , ctx : context } ) ;
162165 isolationScope . setClient ( client ) ;
163166
164167 addCloudResourceContext ( isolationScope ) ;
@@ -185,7 +188,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
185188 captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
186189 throw e ;
187190 } finally {
188- context . waitUntil ( flush ( 2000 ) ) ;
191+ waitUntil ( flush ( 2000 ) ) ;
189192 }
190193 } ,
191194 ) ;
@@ -204,7 +207,9 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
204207 return withIsolationScope ( async isolationScope => {
205208 const options = getFinalOptions ( optionsCallback ( env ) , env ) ;
206209
207- const client = init ( options ) ;
210+ const waitUntil = context . waitUntil . bind ( context ) ;
211+
212+ const client = init ( { ...options , ctx : context } ) ;
208213 isolationScope . setClient ( client ) ;
209214
210215 addCloudResourceContext ( isolationScope ) ;
@@ -215,7 +220,7 @@ export function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostM
215220 captureException ( e , { mechanism : { handled : false , type : 'cloudflare' } } ) ;
216221 throw e ;
217222 } finally {
218- context . waitUntil ( flush ( 2000 ) ) ;
223+ waitUntil ( flush ( 2000 ) ) ;
219224 }
220225 } ) ;
221226 } ,
0 commit comments