@@ -14,6 +14,7 @@ export type Listener = (message: unknown) => void;
1414export class FakeChannel implements MinimalChannel {
1515 listeners : Array < Listener > = [ ] ;
1616
17+ /* c8 ignore next 3 */
1718 get [ Symbol . toStringTag ] ( ) {
1819 return 'FakeChannel' ;
1920 }
@@ -55,7 +56,7 @@ export class FakeChannel implements MinimalChannel {
5556
5657/**
5758 * Structurally-faithful `MinimalTracingChannel` implementation mirroring
58- * Node's `TracingChannel.traceSync` / `tracePromise` lifecycle
59+ * Node's `TracingChannel.traceSync` lifecycle.
5960 */
6061export class FakeTracingChannel implements MinimalTracingChannel {
6162 start : FakeChannel = new FakeChannel ( ) ;
@@ -64,6 +65,7 @@ export class FakeTracingChannel implements MinimalTracingChannel {
6465 asyncEnd : FakeChannel = new FakeChannel ( ) ;
6566 error : FakeChannel = new FakeChannel ( ) ;
6667
68+ /* c8 ignore next 3 */
6769 get [ Symbol . toStringTag ] ( ) {
6870 return 'FakeTracingChannel' ;
6971 }
@@ -95,55 +97,18 @@ export class FakeTracingChannel implements MinimalTracingChannel {
9597 throw err ;
9698 }
9799 // Node's real traceSync sets `ctx.result` before publishing `end`, so
98- // subscribers can inspect `isPromise(ctx.result)` inside their `end`
99- // handler to decide whether the operation is complete or async events
100- // will follow. Match that semantic here.
100+ // subscribers can inspect `ctx.result` inside their `end` handler.
101101 ( ctx as { result : unknown } ) . result = result ;
102102 this . end . publish ( ctx ) ;
103103 return result ;
104104 } ) ;
105105 }
106-
107- tracePromise < T > (
108- fn : ( ...args : Array < unknown > ) => Promise < T > ,
109- ctx : object ,
110- thisArg ?: unknown ,
111- ...args : Array < unknown >
112- ) : Promise < T > {
113- return this . start . runStores ( ctx , ( ) => {
114- let promise : Promise < T > ;
115- try {
116- promise = fn . apply ( thisArg as object , args ) ;
117- } catch ( err ) {
118- ( ctx as { error : unknown } ) . error = err ;
119- this . error . publish ( ctx ) ;
120- this . end . publish ( ctx ) ;
121- throw err ;
122- }
123- this . end . publish ( ctx ) ;
124- this . asyncStart . publish ( ctx ) ;
125- return promise
126- . then (
127- ( result ) => {
128- ( ctx as { result : unknown } ) . result = result ;
129- return result ;
130- } ,
131- ( err : unknown ) => {
132- ( ctx as { error : unknown } ) . error = err ;
133- this . error . publish ( ctx ) ;
134- throw err ;
135- } ,
136- )
137- . finally ( ( ) => {
138- this . asyncEnd . publish ( ctx ) ;
139- } ) ;
140- } ) ;
141- }
142106}
143107
144108export class FakeDc implements MinimalDiagnosticsChannel {
145109 private cache = new Map < string , FakeTracingChannel > ( ) ;
146110
111+ /* c8 ignore next 3 */
147112 get [ Symbol . toStringTag ] ( ) {
148113 return 'FakeDc' ;
149114 }
0 commit comments