From f73e0491e39209b94ab936e93c6415f747be6049 Mon Sep 17 00:00:00 2001 From: Debadree Chatterjee Date: Mon, 28 Nov 2022 20:39:30 +0530 Subject: [PATCH] lib: fix duplexes causing issue --- lib/internal/webstreams/adapters.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/webstreams/adapters.js b/lib/internal/webstreams/adapters.js index 7e2ba628ac8889..02411a07a436a5 100644 --- a/lib/internal/webstreams/adapters.js +++ b/lib/internal/webstreams/adapters.js @@ -101,12 +101,12 @@ function newWritableStreamFromStreamWritable(streamWritable) { // here because it will return false if streamWritable is a Duplex // whose writable option is false. For a Duplex that is not writable, // we want it to pass this check but return a closed WritableStream. - const checkIfWritable = + // We check if the given stream is a stream.Writable or http.OutgoingMessage + const checkIfWritableOrOutgoingMessage = streamWritable && typeof streamWritable?.write === 'function' && - typeof streamWritable?.on === 'function' && - !streamWritable?._readableState; - if (!checkIfWritable) { + typeof streamWritable?.on === 'function'; + if (!checkIfWritableOrOutgoingMessage) { throw new ERR_INVALID_ARG_TYPE( 'streamWritable', 'stream.Writable',