diff --git a/lib/internal/webstreams/adapters.js b/lib/internal/webstreams/adapters.js index 7e8643266e1452..0e844d01200751 100644 --- a/lib/internal/webstreams/adapters.js +++ b/lib/internal/webstreams/adapters.js @@ -5,6 +5,9 @@ const { PromiseResolve, SafePromiseAll, SafePromisePrototypeFinally, + TypedArrayPrototypeGetBuffer, + TypedArrayPrototypeGetByteOffset, + TypedArrayPrototypeGetByteLength, Uint8Array, } = primordials; @@ -267,9 +270,10 @@ function newStreamWritableFromWritableStream(writableStream, options = kEmptyObj } else { chunk = Buffer.from(chunk, encoding); chunk = new Uint8Array( - chunk.buffer, - chunk.byteOffset, - chunk.byteLength); + TypedArrayPrototypeGetBuffer(chunk), + TypedArrayPrototypeGetByteOffset(chunk), + TypedArrayPrototypeGetByteLength(chunk), + ); } } @@ -692,9 +696,10 @@ function newStreamDuplexFromReadableWritablePair(pair = kEmptyObject, options = } else { chunk = Buffer.from(chunk, encoding); chunk = new Uint8Array( - chunk.buffer, - chunk.byteOffset, - chunk.byteLength); + TypedArrayPrototypeGetBuffer(chunk), + TypedArrayPrototypeGetByteOffset(chunk), + TypedArrayPrototypeGetByteLength(chunk), + ); } }