From 89646101208d9d31b1837624073bf619f64edb2b Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 2 Jul 2020 16:45:20 +0100 Subject: [PATCH] fix: work around bug in node that makes writable test fail Exiting an async iterator in a pipline early causes a `ERR_STREAM_PREMATURE_CLOSE` to be thrown. This should be fixed in a future node release: https://github.com/nodejs/node/issues/23890 --- test/helpers/streams.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/helpers/streams.js b/test/helpers/streams.js index 55b1938..4ec4209 100644 --- a/test/helpers/streams.js +++ b/test/helpers/streams.js @@ -4,7 +4,8 @@ const { Writable, pipeline } = require('stream') function pipe (...streams) { return new Promise((resolve, reject) => { pipeline(...streams, err => { - if (err) return reject(err) + // work around bug in node to make 'should end mid stream' test pass - https://github.com/nodejs/node/issues/23890 + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') return reject(err) resolve() }) })