This repository was archived by the owner on Nov 21, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 7979 "express" : " ^4.15.2" ,
8080 "gaxios" : " ^4.0.0" ,
8181 "glob" : " ^7.0.3" ,
82- "grpc" : " 1.24.5 " ,
82+ "grpc" : " 1.24.6 " ,
8383 "gts" : " ^3.0.0" ,
8484 "js-green-licenses" : " ^3.0.0" ,
8585 "linkinator" : " ^2.0.0" ,
Original file line number Diff line number Diff line change @@ -51,31 +51,34 @@ export class AsyncListenerCLS<Context extends {}> implements CLS<Context> {
5151 this . cls . destroyNamespace ( AsyncListenerCLS . TRACE_NAMESPACE ) ;
5252 }
5353
54- private getNamespace ( ) : clsModule . Namespace {
54+ private getNamespace ( ) : clsModule . Namespace | undefined {
5555 return this . cls . getNamespace ( AsyncListenerCLS . TRACE_NAMESPACE ) ;
5656 }
5757
5858 getContext ( ) : Context {
59- const result = this . getNamespace ( ) . get ( AsyncListenerCLS . ROOT_CONTEXT_KEY ) ;
60- if ( result ) {
61- return result ;
59+ const namespace = this . getNamespace ( ) ;
60+ if ( namespace ) {
61+ const result = namespace . get ( AsyncListenerCLS . ROOT_CONTEXT_KEY ) ;
62+ if ( result ) {
63+ return result as Context ;
64+ }
6265 }
6366 return this . defaultContext ;
6467 }
6568
6669 runWithContext < T > ( fn : Func < T > , value : Context ) : T {
6770 const namespace = this . getNamespace ( ) ;
68- return namespace . runAndReturn ( ( ) => {
69- namespace . set ( AsyncListenerCLS . ROOT_CONTEXT_KEY , value ) ;
71+ return namespace ! . runAndReturn ( ( ) => {
72+ namespace ! . set ( AsyncListenerCLS . ROOT_CONTEXT_KEY , value ) ;
7073 return fn ( ) ;
7174 } ) ;
7275 }
7376
7477 bindWithCurrentContext < T > ( fn : Func < T > ) : Func < T > {
75- return this . getNamespace ( ) . bind ( fn ) as Func < T > ;
78+ return this . getNamespace ( ) ! . bind ( fn ) as Func < T > ;
7679 }
7780
7881 patchEmitterToPropagateContext ( ee : EventEmitter ) : void {
79- return this . getNamespace ( ) . bindEmitter ( ee ) ;
82+ return this . getNamespace ( ) ! . bindEmitter ( ee ) ;
8083 }
8184}
You can’t perform that action at this time.
0 commit comments