From 0ce9a9caae5b0a8a09b4b36a250e50b682f97a4f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 20 Nov 2019 09:55:29 -0800 Subject: [PATCH] test: replace setTimeout with setImmediate in stream test Replace setTimeout() with setImmediate() in test-stream-writable-clear-buffer. The test still fails in Node.js 8.6.0 (if you comment out the `common` module, since it uses BigInts and those aren't supported in 8.6.0). PR-URL: https://github.com/nodejs/node/pull/30561 Reviewed-By: Denys Otrishko Reviewed-By: Anna Henningsen --- test/sequential/test-stream-writable-clear-buffer.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/sequential/test-stream-writable-clear-buffer.js b/test/sequential/test-stream-writable-clear-buffer.js index dc859e3fb6b362..f2d1e000cfde3e 100644 --- a/test/sequential/test-stream-writable-clear-buffer.js +++ b/test/sequential/test-stream-writable-clear-buffer.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const Stream = require('stream'); // This test ensures that the _writeableState.bufferedRequestCount and // the actual buffered request count are the same @@ -10,11 +10,12 @@ class StreamWritable extends Stream.Writable { super({ objectMode: true }); } - // We need a timeout like on the original issue thread - // otherwise the code will never reach our test case - // this means this should go on the sequential folder. + // Refs: https://github.com/nodejs/node/issues/6758 + // We need a timer like on the original issue thread. + // Otherwise the code will never reach our test case. + // This means this should go in the sequential folder. _write(chunk, encoding, cb) { - setTimeout(cb, common.platformTimeout(10)); + setImmediate(cb); } }