From 1e1822b65cc11d799ec490efa8f8702b90a5a9c5 Mon Sep 17 00:00:00 2001 From: voltrexmaster Date: Tue, 26 Oct 2021 21:12:44 -0700 Subject: [PATCH] stream: rename unknown primordial The primordials does not expose a primordial called `DataViewCtor`, leading up to a non-existent constructor. Fixes: https://github.com/nodejs/node/issues/40612 --- lib/internal/webstreams/readablestream.js | 4 ++-- test/parallel/test-whatwg-readablestream.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/internal/webstreams/readablestream.js b/lib/internal/webstreams/readablestream.js index fe9b26b991f04e..af4937f3c772a5 100644 --- a/lib/internal/webstreams/readablestream.js +++ b/lib/internal/webstreams/readablestream.js @@ -7,7 +7,7 @@ const { ArrayBufferPrototypeSlice, ArrayPrototypePush, ArrayPrototypeShift, - DataViewCtor, + DataView, FunctionPrototypeBind, FunctionPrototypeCall, MathMin, @@ -2100,7 +2100,7 @@ function readableByteStreamControllerPullInto( pendingPullIntos, } = controller[kState]; let elementSize = 1; - let ctor = DataViewCtor; + let ctor = DataView; if (isArrayBufferView(view) && !isDataView(view)) { elementSize = view.constructor.BYTES_PER_ELEMENT; ctor = view.constructor; diff --git a/test/parallel/test-whatwg-readablestream.js b/test/parallel/test-whatwg-readablestream.js index c8b82fa9823786..49204856d3c339 100644 --- a/test/parallel/test-whatwg-readablestream.js +++ b/test/parallel/test-whatwg-readablestream.js @@ -1570,3 +1570,18 @@ class Source { isDisturbed(stream, true); })().then(common.mustCall()); } + +{ + const stream = new ReadableStream({ + type: 'bytes', + start(controller) { + controller.close(); + } + }); + + const buffer = new ArrayBuffer(1024); + const reader = stream.getReader({ mode: 'byob' }); + + reader.read(new DataView(buffer)) + .then(common.mustCall()); +}