@@ -187,43 +187,40 @@ export function requestHandler(
187187 } ) ;
188188 } ;
189189 }
190- runWithAsyncContext (
191- currentHub => {
192- currentHub . configureScope ( scope => {
193- scope . setSDKProcessingMetadata ( {
194- request : req ,
195- // TODO (v8): Stop passing this
196- requestDataOptionsFromExpressHandler : requestDataOptions ,
197- } ) ;
190+ runWithAsyncContext ( currentHub => {
191+ currentHub . configureScope ( scope => {
192+ scope . setSDKProcessingMetadata ( {
193+ request : req ,
194+ // TODO (v8): Stop passing this
195+ requestDataOptionsFromExpressHandler : requestDataOptions ,
196+ } ) ;
198197
199- const client = currentHub . getClient < NodeClient > ( ) ;
200- if ( isAutoSessionTrackingEnabled ( client ) ) {
201- const scope = currentHub . getScope ( ) ;
202- if ( scope ) {
203- // Set `status` of `RequestSession` to Ok, at the beginning of the request
204- scope . setRequestSession ( { status : 'ok' } ) ;
205- }
198+ const client = currentHub . getClient < NodeClient > ( ) ;
199+ if ( isAutoSessionTrackingEnabled ( client ) ) {
200+ const scope = currentHub . getScope ( ) ;
201+ if ( scope ) {
202+ // Set `status` of `RequestSession` to Ok, at the beginning of the request
203+ scope . setRequestSession ( { status : 'ok' } ) ;
206204 }
207- } ) ;
205+ }
206+ } ) ;
208207
209- res . once ( 'finish' , ( ) => {
210- const client = currentHub . getClient < NodeClient > ( ) ;
211- if ( isAutoSessionTrackingEnabled ( client ) ) {
212- setImmediate ( ( ) => {
208+ res . once ( 'finish' , ( ) => {
209+ const client = currentHub . getClient < NodeClient > ( ) ;
210+ if ( isAutoSessionTrackingEnabled ( client ) ) {
211+ setImmediate ( ( ) => {
212+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
213+ if ( client && ( client as any ) . _captureRequestSession ) {
214+ // Calling _captureRequestSession to capture request session at the end of the request by incrementing
215+ // the correct SessionAggregates bucket i.e. crashed, errored or exited
213216 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
214- if ( client && ( client as any ) . _captureRequestSession ) {
215- // Calling _captureRequestSession to capture request session at the end of the request by incrementing
216- // the correct SessionAggregates bucket i.e. crashed, errored or exited
217- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
218- ( client as any ) . _captureRequestSession ( ) ;
219- }
220- } ) ;
221- }
222- } ) ;
223- next ( ) ;
224- } ,
225- { emitters : [ req , res ] } ,
226- ) ;
217+ ( client as any ) . _captureRequestSession ( ) ;
218+ }
219+ } ) ;
220+ }
221+ } ) ;
222+ next ( ) ;
223+ } ) ;
227224 } ;
228225}
229226
0 commit comments