Skip to content

Commit

Permalink
stream: use structuredClone instead of v8
Browse files Browse the repository at this point in the history
PR-URL: nodejs#45611
Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
anonrig authored and ErickWendel committed Nov 30, 2022
1 parent 6f0ac74 commit 3678da4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/internal/webstreams/readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ const {
kEnumerableProperty,
} = require('internal/util');

const {
serialize,
deserialize,
} = require('v8');

const {
validateBuffer,
validateObject,
Expand Down Expand Up @@ -91,6 +86,10 @@ const {
kIsReadable,
} = require('internal/streams/utils');

const {
structuredClone,
} = require('internal/structured_clone');

const {
ArrayBufferViewGetBuffer,
ArrayBufferViewGetByteLength,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 3678da4

Please sign in to comment.