Skip to content

Commit

Permalink
fix(tracer): tracer does not have close method if it is not enabled (#24
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ValeraS authored Aug 31, 2023
1 parent 6798b40 commit 98c4a96
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/nodekit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,17 @@ export class NodeKit {

this.ctx.stats = prepareClickhouseClient(this.ctx);

this.addShutdownHandler(() => new Promise<void>((resolve) => this.tracer.close(resolve)));
this.addShutdownHandler(
() =>
new Promise<void>((resolve) => {
// if tracing is disabled, initTracer returns object without close method
if (typeof this.tracer.close === 'function') {
this.tracer.close(resolve);
} else {
resolve();
}
}),
);

this.setupShutdownSignals();
}
Expand Down

0 comments on commit 98c4a96

Please sign in to comment.