@@ -28,7 +28,6 @@ import {
2828}  from  '@sentry/utils' ; 
2929
3030import  {  IntegrationIndex ,  setupIntegrations  }  from  './integration' ; 
31- import  {  NoopTransport  }  from  './transports/noop' ; 
3231
3332const  ALREADY_SEEN_ERROR  =  "Not capturing exception because it's already been captured." ; 
3433
@@ -76,7 +75,7 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
7675  protected  _numProcessing : number  =  0 ; 
7776
7877  /** Cached transport used internally. */ 
79-   protected  _transport : Transport ; 
78+   protected  _transport : Transport   |   undefined ; 
8079
8180  /** 
8281   * Initializes this client instance. 
@@ -194,7 +193,7 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
194193  /** 
195194   * @inheritDoc  
196195   */ 
197-   public  getTransport ( ) : Transport  { 
196+   public  getTransport ( ) : Transport  |   undefined   { 
198197    return  this . _transport ; 
199198  } 
200199
@@ -203,9 +202,11 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
203202   */ 
204203  public  flush ( timeout ?: number ) : PromiseLike < boolean >  { 
205204    return  this . _isClientDoneProcessing ( timeout ) . then ( clientFinished  =>  { 
206-       return  this . getTransport ( ) 
207-         . close ( timeout ) 
208-         . then ( transportFlushed  =>  clientFinished  &&  transportFlushed ) ; 
205+       const  transport  =  this . getTransport ( ) ; 
206+       if  ( transport )  { 
207+         return  transport . close ( timeout ) . then ( transportFlushed  =>  clientFinished  &&  transportFlushed ) ; 
208+       } 
209+       return  false ; 
209210    } ) ; 
210211  } 
211212
@@ -244,21 +245,28 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
244245   * @inheritDoc  
245246   */ 
246247  public  sendEvent ( event : Event ) : void { 
247-     void  this . _transport . sendEvent ( event ) . then ( null ,  reason  =>  { 
248-       logger . error ( `Error while sending event: ${ reason }  ) ; 
249-     } ) ; 
248+     const  transport  =  this . getTransport ( ) ; 
249+     if  ( transport )  { 
250+       void  transport . sendEvent ( event ) . then ( null ,  reason  =>  { 
251+         logger . error ( `Error while sending event: ${ reason }  ) ; 
252+       } ) ; 
253+     } 
250254  } 
251255
252256  /** 
253257   * @inheritDoc  
254258   */ 
255259  public  sendSession ( session : Session ) : void { 
256-     if  ( ! this . _transport . sendSession )  { 
260+     const  transport  =  this . getTransport ( ) ; 
261+     if  ( ! transport )  { 
262+       return ; 
263+     } 
264+     if  ( ! transport . sendSession )  { 
257265      logger . warn ( "Dropping session because custom transport doesn't implement sendSession" ) ; 
258266      return ; 
259267    } 
260268
261-     void  this . _transport . sendSession ( session ) . then ( null ,  reason  =>  { 
269+     void  transport . sendSession ( session ) . then ( null ,  reason  =>  { 
262270      logger . error ( `Error while sending session: ${ reason }  ) ; 
263271    } ) ; 
264272  } 
@@ -525,7 +533,7 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
525533    type  RecordLostEventParams  =  Parameters < RecordLostEvent > ; 
526534
527535    function  recordLostEvent ( outcome : RecordLostEventParams [ 0 ] ,  category : RecordLostEventParams [ 1 ] ) : void { 
528-       if  ( transport . recordLostEvent )  { 
536+       if  ( transport   &&   transport . recordLostEvent )  { 
529537        transport . recordLostEvent ( outcome ,  category ) ; 
530538      } 
531539    } 
@@ -613,8 +621,8 @@ export abstract class BaseClient<O extends Options> implements Client<O> {
613621  /** 
614622   * Sets up the transport so it can be used later to send requests. 
615623   */ 
616-   protected  _setupTransport ( ) : Transport  { 
617-     return  new   NoopTransport ( ) ; 
624+   protected  _setupTransport ( ) : Transport  |   undefined   { 
625+     return  undefined ; 
618626  } 
619627
620628  /** 
0 commit comments