Skip to content

Commit

Permalink
Avoid structuredClone
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <[email protected]>
  • Loading branch information
mcollina committed Jan 16, 2024
1 parent 3372aed commit 35c431c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/fetch/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,13 @@ function cloneBody (body) {

// 1. Let « out1, out2 » be the result of teeing body’s stream.
const [out1, out2] = body.stream.tee()
const out2Clone = structuredClone(out2, { transfer: [out2] })
// This, for whatever reasons, unrefs out2Clone which allows
// the process to exit by itself.
const [, finalClone] = out2Clone.tee()

// 2. Set body’s stream to out1.
body.stream = out1

// 3. Return a body whose stream is out2 and other members are copied from body.
return {
stream: finalClone,
stream: out2,
length: body.length,
source: body.source
}
Expand Down

0 comments on commit 35c431c

Please sign in to comment.