From 985842debef1078025d4268904a82916e66444a2 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Sat, 26 Nov 2022 23:47:41 -0500 Subject: [PATCH] stream: use structuredClone instead of v8 PR-URL: https://github.com/nodejs/node/pull/45611 Reviewed-By: Erick Wendel Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca --- lib/internal/webstreams/readablestream.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/internal/webstreams/readablestream.js b/lib/internal/webstreams/readablestream.js index bbc47f49643425..2dfcf90bce34b4 100644 --- a/lib/internal/webstreams/readablestream.js +++ b/lib/internal/webstreams/readablestream.js @@ -55,11 +55,6 @@ const { kEnumerableProperty, } = require('internal/util'); -const { - serialize, - deserialize, -} = require('v8'); - const { validateBuffer, validateObject, @@ -90,6 +85,10 @@ const { kIsReadable, } = require('internal/streams/utils'); +const { + structuredClone, +} = require('internal/structured_clone'); + const { ArrayBufferViewGetBuffer, ArrayBufferViewGetByteLength, @@ -1470,8 +1469,7 @@ function readableStreamDefaultTee(stream, cloneForBranch2) { const value1 = value; let value2 = value; if (!canceled2 && cloneForBranch2) { - // Structured Clone - value2 = deserialize(serialize(value2)); + value2 = structuredClone(value2); } if (!canceled1) { readableStreamDefaultControllerEnqueue(