diff --git a/test/parallel/test-whatwg-webstreams-compression.js b/test/parallel/test-whatwg-webstreams-compression.js index 6d3d6253bd1b86..859df4e07bed88 100644 --- a/test/parallel/test-whatwg-webstreams-compression.js +++ b/test/parallel/test-whatwg-webstreams-compression.js @@ -20,11 +20,19 @@ async function test(format) { const reader = gunzip.readable.getReader(); const writer = gzip.writable.getWriter(); + const compressed_data = []; + const reader_function = ({ value, done }) => { + if (value) + compressed_data.push(value); + if (!done) + return reader.read().then(reader_function); + assert.strictEqual(dec.decode(Buffer.concat(compressed_data)), 'hello'); + }; + const reader_promise = reader.read().then(reader_function); + await Promise.all([ - reader.read().then(({ value, done }) => { - assert.strictEqual(dec.decode(value), 'hello'); - }), - reader.read().then(({ done }) => assert(done)), + reader_promise, + reader_promise.then(() => reader.read().then(({ done }) => assert(done))), writer.write('hello'), writer.close(), ]);