From 7794d4e0b857967cd9ec2ef84a7c20c08cdbe78c Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Wed, 22 Aug 2018 10:46:50 +0200 Subject: [PATCH] test,stream: fix pipeline test so it runs well on Windows in older nodes This test is ported automatically in readable-stream, and it fails there on Windows and older Node.js versions because of some bad interactions between the code and the event loop on Windows. See: https://github.com/nodejs/readable-stream/issues/353 PR-URL: https://github.com/nodejs/node/pull/22456 Reviewed-By: Mathias Buus Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- test/parallel/test-stream-pipeline.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js index 89cde367ad6f7b..a1bcdb4b62485c 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -165,8 +165,13 @@ const { promisify } = require('util'); { const server = http.createServer((req, res) => { + let sent = false; const rs = new Readable({ read() { + if (sent) { + return; + } + sent = true; rs.push('hello'); }, destroy: common.mustCall((err, cb) => { @@ -195,8 +200,12 @@ const { promisify } = require('util'); { const server = http.createServer((req, res) => { + let sent = 0; const rs = new Readable({ read() { + if (sent++ > 10) { + return; + } rs.push('hello'); }, destroy: common.mustCall((err, cb) => { @@ -242,8 +251,12 @@ const { promisify } = require('util'); port: server.address().port }); + let sent = 0; const rs = new Readable({ read() { + if (sent++ > 10) { + return; + } rs.push('hello'); } });