Skip to content

Commit

Permalink
lib: allow Writeable.toWeb() to work on http.Outgoing message
Browse files Browse the repository at this point in the history
Attempted to fix the issue by watering down the condition being
checked in internal/streams/utils isWritableNodeStream utility

Fixes: nodejs#44188
  • Loading branch information
debadree25 committed Nov 28, 2022
1 parent 60810f0 commit 093aa39
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/internal/webstreams/adapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,17 @@ 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.
if (typeof streamWritable?._writableState !== 'object') {
const checkIfWritable =
streamWritable &&
typeof streamWritable?.write === 'function' &&
typeof streamWritable?.on === 'function' &&
!streamWritable?._readableState;
if (!checkIfWritable) {
throw new ERR_INVALID_ARG_TYPE(
'streamWritable',
'stream.Writable',
streamWritable);
streamWritable
);
}

if (isDestroyed(streamWritable) || !isWritable(streamWritable)) {
Expand Down

0 comments on commit 093aa39

Please sign in to comment.