fix: resolve BlobPart type incompatibility between Deno and Node.js

Use .slice() on Uint8Array values before passing to File/Blob constructors
to create fresh ArrayBuffer-backed arrays, avoiding type errors from
ArrayBufferLike vs ArrayBuffer differences in TypeScript definitions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-01-17 21:18:51 +00:00
parent 437025a078
commit 2eac74cef4

View File

@@ -314,7 +314,8 @@ export async function handleFile(
continue;
}
log.info(`Adding file: ${file.path.substring(1)}`);
const fil = new File([file.contents as BlobPart], file.path.substring(1));
// .slice() creates new ArrayBuffer, needed for cross-platform compatibility
const fil = new File([file.contents.slice()], file.path.substring(1));
tarball.append(fil);
}
const endTime = performance.now();
@@ -541,8 +542,8 @@ async function streamToBlob(stream: ReadableStream<Uint8Array>): Promise<Blob> {
chunks.push(value);
}
// Create a Blob from the chunks
const blob = new Blob(chunks as BlobPart[]);
// Create a Blob from the chunks (.map with slice for cross-platform compatibility)
const blob = new Blob(chunks.map(c => c.slice()));
return blob;
}