From 63295b62e7e5a9d50be812c0f204887dcf87a431 Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Thu, 19 Sep 2024 11:12:24 +0200 Subject: [PATCH] fix: handle end and finish events --- packages/core/lib/Pipeline.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/lib/Pipeline.ts b/packages/core/lib/Pipeline.ts index 8de42c89..797c87db 100644 --- a/packages/core/lib/Pipeline.ts +++ b/packages/core/lib/Pipeline.ts @@ -116,8 +116,11 @@ class Pipeline extends StreamObject { this.children[index].stream.pipe(child.stream) } + const finished = once(() => this.finish()) + this.lastChild.stream.on('error', this.logger.error.bind(this.logger)) - this.lastChild.stream.on('end', this.finish.bind(this)) + this.lastChild.stream.on('end', finished) + this.lastChild.stream.on('finish', finished) } catch (err: any) { // eslint-disable-line @typescript-eslint/no-explicit-any this.destroy(err)