@@ -281,7 +281,7 @@ function tracingChannelFrom(nameOrChannels, name) {
281281}
282282
283283class TracingChannel {
284- #nextChannel
284+ #nextChannel;
285285
286286 constructor ( nameOrChannels ) {
287287 for ( let i = 0 ; i < traceEvents . length ; ++ i ) {
@@ -438,17 +438,13 @@ class TracingChannel {
438438
439439 const { start, end, asyncStart, asyncEnd, error } = this ;
440440
441- if ( ! this . #nextChannel) {
442- this . #nextChannel = tracingChannel ( {
443- start : channel ( start . name . slice ( 0 , - 6 ) + ':next:start' ) ,
444- end : channel ( end . name . slice ( 0 , - 4 ) + ':next:end' ) ,
445- asyncStart : channel ( asyncStart . name . slice ( 0 , - 11 ) + ':next:asyncStart' ) ,
446- asyncEnd : channel ( asyncEnd . name . slice ( 0 , - 9 ) + ':next:asyncEnd' ) ,
447- error : channel ( error . name . slice ( 0 , - 6 ) + ':next:error' ) ,
448- } ) ;
449- }
450-
451- const nextChannel = this . #nextChannel;
441+ const nextChannel = this . #nextChannel ||= tracingChannel ( {
442+ start : channel ( start . name . slice ( 0 , - 6 ) + ':next:start' ) ,
443+ end : channel ( end . name . slice ( 0 , - 4 ) + ':next:end' ) ,
444+ asyncStart : channel ( asyncStart . name . slice ( 0 , - 11 ) + ':next:asyncStart' ) ,
445+ asyncEnd : channel ( asyncEnd . name . slice ( 0 , - 9 ) + ':next:asyncEnd' ) ,
446+ error : channel ( error . name . slice ( 0 , - 6 ) + ':next:error' ) ,
447+ } ) ;
452448
453449 const wrapIter = ( iter ) => {
454450 const { next : iterNext , return : iterReturn , throw : iterThrow } = iter ;
@@ -465,9 +461,9 @@ class TracingChannel {
465461
466462 const result = this . #traceMaybePromise( fn , context , thisArg , ...args ) ;
467463
468- return result instanceof Promise
469- ? PromisePrototypeThen ( result , wrapIter )
470- : wrapIter ( result ) ;
464+ return result instanceof Promise ?
465+ PromisePrototypeThen ( result , wrapIter ) :
466+ wrapIter ( result ) ;
471467 }
472468
473469 #traceMaybePromise( fn , context = { } , thisArg , ...args ) {
@@ -499,8 +495,8 @@ class TracingChannel {
499495 const result = ReflectApply ( fn , thisArg , args ) ;
500496 // TODO: Should tracePromise just always do this?
501497 if ( ! ( result instanceof Promise ) ) {
502- context . result = result
503- return result
498+ context . result = result ;
499+ return result ;
504500 }
505501 return PromisePrototypeThen ( result , resolve , reject ) ;
506502 } catch ( err ) {
0 commit comments