@@ -9,6 +9,7 @@ import type { AggregationCounts, Client, RequestEventData, SanitizedRequestData,
99import  { 
1010  addBreadcrumb , 
1111  getBreadcrumbLogLevelFromHttpStatusCode , 
12+   getClient , 
1213  getIsolationScope , 
1314  getSanitizedUrlString , 
1415  httpRequestToRequestData , 
@@ -23,11 +24,11 @@ import { getRequestInfo } from './vendor/getRequestInfo';
2324
2425const  clientToAggregatesMap  =  new  Map < 
2526  Client , 
26-   {  [ timestampRoundedToSeconds : string ] : {  exited : number ;  errored : number  }  } 
27+   {  [ timestampRoundedToSeconds : string ] : {  exited : number ;  crashed : number  }  } 
2728> ( ) ; 
2829
2930interface  RequestSession  { 
30-   status : 'ok'  |  'errored ' ; 
31+   status : 'ok'  |  'crashed ' ; 
3132} 
3233
3334type  Http  =  typeof  http ; 
@@ -178,7 +179,8 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
178179            requestSession : {  status : 'ok'  } , 
179180          } ) ; 
180181          response . once ( 'close' ,  ( )  =>  { 
181-             const  client  =  isolationScope . getClient ( ) ; 
182+             // We need to grab the client off the current scope instead of the isolation scope because the isolation scope doesn't hold any client out of the box. 
183+             const  client  =  getClient ( ) ; 
182184            const  requestSession  =  isolationScope . getScopeData ( ) . sdkProcessingMetadata . requestSession  as 
183185              |  RequestSession 
184186              |  undefined ; 
@@ -191,13 +193,13 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
191193              const  existingClientAggregate  =  clientToAggregatesMap . get ( client ) ; 
192194              if  ( existingClientAggregate )  { 
193195                DEBUG_BUILD  &&  logger . debug ( `Recorded request session with status: ${ requestSession . status }  ` ) ; 
194-                 const  bucket  =  existingClientAggregate [ dateBucketKey ]  ||  {  errored : 0 ,  exited : 0  } ; 
195-                 bucket [ requestSession . status  ===  'ok'  ? 'exited'  : 'errored ' ] ++ ; 
196+                 const  bucket  =  existingClientAggregate [ dateBucketKey ]  ||  {  crashed : 0 ,  exited : 0  } ; 
197+                 bucket [ requestSession . status  ===  'ok'  ? 'exited'  : 'crashed ' ] ++ ; 
196198                existingClientAggregate [ dateBucketKey ]  =  bucket ; 
197199              }  else  { 
198200                DEBUG_BUILD  &&  logger . debug ( 'Opened new request session aggregate.' ) ; 
199-                 const  bucket  =  {  errored : 0 ,  exited : 0  } ; 
200-                 bucket [ requestSession . status  ===  'ok'  ? 'exited'  : 'errored ' ] ++ ; 
201+                 const  bucket  =  {  crashed : 0 ,  exited : 0  } ; 
202+                 bucket [ requestSession . status  ===  'ok'  ? 'exited'  : 'crashed ' ] ++ ; 
201203                const  newClientAggregate  =  {  [ dateBucketKey ] : bucket  } ; 
202204                clientToAggregatesMap . set ( client ,  newClientAggregate ) ; 
203205
@@ -210,7 +212,7 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
210212                    ( [ timestamp ,  value ] )  =>  ( { 
211213                      started : timestamp , 
212214                      exited : value . exited , 
213-                       errored : value . errored , 
215+                       crashed : value . crashed , 
214216                    } ) , 
215217                  ) ; 
216218                  client . sendSession ( {  aggregates : aggregatePayload  } ) ; 
@@ -223,7 +225,8 @@ export class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpIns
223225                const  timeout  =  setTimeout ( ( )  =>  { 
224226                  DEBUG_BUILD  &&  logger . debug ( 'Sending request session aggregate due to flushing schedule' ) ; 
225227                  flushPendingClientAggregates ( ) ; 
226-                 } ,  60_000 ) . unref ( ) ; 
228+                   // TODO: Increase to 60s 
229+                 } ,  5_000 ) . unref ( ) ; 
227230              } 
228231            } 
229232          } ) ; 
0 commit comments