From 27df67ab9ac74eb0f8d5193cead5c8ea898dae88 Mon Sep 17 00:00:00 2001 From: Nicolas Thouvenin Date: Thu, 12 Oct 2023 10:42:02 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20avoid=20to=20write=20in?= =?UTF-8?q?=20closed=20stream?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/engine.js | 4 +++- packages/core/src/statements/fork.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/src/engine.js b/packages/core/src/engine.js index db1d1c2d..ed7b4296 100644 --- a/packages/core/src/engine.js +++ b/packages/core/src/engine.js @@ -152,7 +152,9 @@ export default class Engine extends SafeTransform { debug('ezs')(`Ignoring error at item #${currentIndex}`); return this.push(createErrorWith(data, currentIndex, this.funcName, chunk)); } - return this.push(data); + if (!this.errorWasSent) { + return this.push(data); + } }; const wait = async () => { this.pause(); diff --git a/packages/core/src/statements/fork.js b/packages/core/src/statements/fork.js index 8171129c..918823a0 100644 --- a/packages/core/src/statements/fork.js +++ b/packages/core/src/statements/fork.js @@ -49,8 +49,8 @@ export default function fork(data, feed) { this.whenFinish = new Promise((resolve) => output .pipe(ezs.catch((e) => feed.write(e))) // avoid to break pipeline at each error .once('error', (e) => feed.stop(e)) - .once('end', resolve) .on('data', () => true) + .once('end', resolve) ); } }