Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/core/core/src/requests/WriteBundleRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ async function runCompressor(
}
}

function replaceStream(hashRefToNameHash) {
export function replaceStream(
hashRefToNameHash: Map<string, string>,
): Transform {
let boundaryStr = Buffer.alloc(0);
let replaced = Buffer.alloc(0);
return new Transform({
Expand Down Expand Up @@ -348,9 +350,10 @@ function replaceStream(hashRefToNameHash) {
replacedLength - BOUNDARY_LENGTH,
replacedLength,
);
let strUpToBoundary = replaced.subarray(
0,
replacedLength - BOUNDARY_LENGTH,
// Copy buffer to avoid reuse issues - subarray returns a view that can be
// corrupted if the underlying buffer is modified before the data is written
let strUpToBoundary = Buffer.from(
replaced.subarray(0, replacedLength - BOUNDARY_LENGTH),
);
cb(null, strUpToBoundary);
},
Expand Down
Loading