From dc99ae3bd63fe31d2f4d2472ced7cc0f8786a088 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 17 Nov 2021 16:58:02 -0800 Subject: [PATCH] stream: fix the ReadableStreamBYOBReader error message PR-URL: https://github.com/nodejs/node/pull/40846 Reviewed-By: Robert Nagy --- lib/internal/webstreams/readablestream.js | 4 +++- test/parallel/test-whatwg-readablestream.js | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/internal/webstreams/readablestream.js b/lib/internal/webstreams/readablestream.js index fe9b26b991f04e..c9b988d6fee0f7 100644 --- a/lib/internal/webstreams/readablestream.js +++ b/lib/internal/webstreams/readablestream.js @@ -508,6 +508,8 @@ class ReadableStream { return customInspect(depth, options, this[kType], { locked: this.locked, state: this[kState].state, + supportsBYOB: + this[kState].controller instanceof ReadableByteStreamController, }); } @@ -1745,7 +1747,7 @@ function setupReadableStreamBYOBReader(reader, stream) { controller, } = stream[kState]; if (!isReadableByteStreamController(controller)) - throw new ERR_INVALID_ARG_VALUE('reader', reader, 'must be a byte stream'); + throw new ERR_INVALID_ARG_VALUE('stream', stream, 'must be a byte stream'); readableStreamReaderGenericInitialize(reader, stream); reader[kState].readIntoRequests = []; } diff --git a/test/parallel/test-whatwg-readablestream.js b/test/parallel/test-whatwg-readablestream.js index c8b82fa9823786..ce1d892262be16 100644 --- a/test/parallel/test-whatwg-readablestream.js +++ b/test/parallel/test-whatwg-readablestream.js @@ -1410,10 +1410,12 @@ class Source { assert.strictEqual( inspect(readable), - 'ReadableStream { locked: false, state: \'readable\' }'); + 'ReadableStream { locked: false, state: \'readable\', ' + + 'supportsBYOB: false }'); assert.strictEqual( inspect(readable, { depth: null }), - 'ReadableStream { locked: false, state: \'readable\' }'); + 'ReadableStream { locked: false, state: \'readable\', ' + + 'supportsBYOB: false }'); assert.strictEqual( inspect(readable, { depth: 0 }), 'ReadableStream [Object]');