diff --git a/lib/internal/streams/readable.js b/lib/internal/streams/readable.js index bd9c288aa71929..4975d3c054016f 100644 --- a/lib/internal/streams/readable.js +++ b/lib/internal/streams/readable.js @@ -1166,8 +1166,8 @@ ObjectDefineProperties(Readable.prototype, { // where the readable side was disabled upon construction. // Compat. The user might manually disable readable side through // deprecated setter. - return !!r && r.readable !== false && !r.destroyed && !r.errorEmitted && - !r.endEmitted; + if (!r || r.readable === false) return; + return !r.destroyed && !r.errorEmitted && !r.endEmitted; }, set(val) { // Backwards compat. diff --git a/lib/internal/streams/writable.js b/lib/internal/streams/writable.js index 92e982e4821586..1cb5be736d7627 100644 --- a/lib/internal/streams/writable.js +++ b/lib/internal/streams/writable.js @@ -793,8 +793,8 @@ ObjectDefineProperties(Writable.prototype, { // where the writable side was disabled upon construction. // Compat. The user might manually disable writable side through // deprecated setter. - return !!w && w.writable !== false && !w.destroyed && !w.errored && - !w.ending && !w.ended; + if (!w || w.writable === false) return; + return !w.destroyed && !w.errored && !w.ending && !w.ended; }, set(val) { // Backwards compatible. diff --git a/test/parallel/test-stream-compose.js b/test/parallel/test-stream-compose.js index c3d52e08e0048e..21f73cd5af88eb 100644 --- a/test/parallel/test-stream-compose.js +++ b/test/parallel/test-stream-compose.js @@ -274,8 +274,8 @@ const assert = require('assert'); } }); - assert.strictEqual(s1.writable, false); - assert.strictEqual(s1.readable, false); + assert.strictEqual(s1.writable, undefined); + assert.strictEqual(s1.readable, undefined); finished(s1.resume(), common.mustCall((err) => { assert(!err); diff --git a/test/parallel/test-stream-duplex-from.js b/test/parallel/test-stream-duplex-from.js index 446768d6eef3e3..64f3fde1e9f962 100644 --- a/test/parallel/test-stream-duplex-from.js +++ b/test/parallel/test-stream-duplex-from.js @@ -14,7 +14,7 @@ const { Duplex, Readable, Writable, pipeline } = require('stream'); }) }); assert.strictEqual(d.readable, true); - assert.strictEqual(d.writable, false); + assert.strictEqual(d.writable, undefined); d.once('readable', common.mustCall(function() { assert.strictEqual(d.read().toString(), 'asd'); })); @@ -31,7 +31,7 @@ const { Duplex, Readable, Writable, pipeline } = require('stream'); } })); assert.strictEqual(d.readable, true); - assert.strictEqual(d.writable, false); + assert.strictEqual(d.writable, undefined); d.once('readable', common.mustCall(function() { assert.strictEqual(d.read().toString(), 'asd'); })); @@ -48,7 +48,7 @@ const { Duplex, Readable, Writable, pipeline } = require('stream'); callback(); } })); - assert.strictEqual(d.readable, false); + assert.strictEqual(d.readable, undefined); assert.strictEqual(d.writable, true); d.end('asd'); d.on('finish', common.mustCall(function() { @@ -67,7 +67,7 @@ const { Duplex, Readable, Writable, pipeline } = require('stream'); } }) }); - assert.strictEqual(d.readable, false); + assert.strictEqual(d.readable, undefined); assert.strictEqual(d.writable, true); d.end('asd'); d.on('finish', common.mustCall(function() { @@ -110,7 +110,7 @@ const { Duplex, Readable, Writable, pipeline } = require('stream'); { const d = Duplex.from(Promise.resolve('asd')); assert.strictEqual(d.readable, true); - assert.strictEqual(d.writable, false); + assert.strictEqual(d.writable, undefined); d.once('readable', common.mustCall(function() { assert.strictEqual(d.read().toString(), 'asd'); })); diff --git a/test/parallel/test-stream-duplex-readable-writable.js b/test/parallel/test-stream-duplex-readable-writable.js index aec88fc120b1c5..86635a4a3018d1 100644 --- a/test/parallel/test-stream-duplex-readable-writable.js +++ b/test/parallel/test-stream-duplex-readable-writable.js @@ -8,7 +8,7 @@ const assert = require('assert'); const duplex = new Duplex({ readable: false }); - assert.strictEqual(duplex.readable, false); + assert.strictEqual(duplex.readable, undefined); duplex.push('asd'); duplex.on('error', common.mustCall((err) => { assert.strictEqual(err.code, 'ERR_STREAM_PUSH_AFTER_EOF'); @@ -22,7 +22,7 @@ const assert = require('assert'); writable: false, write: common.mustNotCall() }); - assert.strictEqual(duplex.writable, false); + assert.strictEqual(duplex.writable, undefined); duplex.write('asd'); duplex.on('error', common.mustCall((err) => { assert.strictEqual(err.code, 'ERR_STREAM_WRITE_AFTER_END'); @@ -34,7 +34,7 @@ const assert = require('assert'); const duplex = new Duplex({ readable: false }); - assert.strictEqual(duplex.readable, false); + assert.strictEqual(duplex.readable, undefined); duplex.on('data', common.mustNotCall()); duplex.on('end', common.mustNotCall()); async function run() {