From 98c4a9660279c43e7baf6c18c4998ba417bcf5d0 Mon Sep 17 00:00:00 2001 From: Valerii Sidorenko Date: Thu, 31 Aug 2023 16:45:25 +0200 Subject: [PATCH] fix(tracer): tracer does not have close method if it is not enabled (#24) --- src/nodekit.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/nodekit.ts b/src/nodekit.ts index 2d0c2fb..fceced0 100644 --- a/src/nodekit.ts +++ b/src/nodekit.ts @@ -124,7 +124,17 @@ export class NodeKit { this.ctx.stats = prepareClickhouseClient(this.ctx); - this.addShutdownHandler(() => new Promise((resolve) => this.tracer.close(resolve))); + this.addShutdownHandler( + () => + new Promise((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(); }