Streaming zip to a file keeps Deno hanged for a moment #612
-
|
Hello! I'm running this code: import { BlobWriter, TextReader, ZipWriter } from "jsr:@zip-js/zip-js";
// ----
// Write the zip file
// ----
// Creates a BlobWriter object where the zip content will be written.
const zipFileWriter = new BlobWriter();
// Creates a TextReader object storing the text of the entry to add in the zip
// (i.e. "Hello world!").
const helloWorldReader = new TextReader("Hello world!");
// Creates a ZipWriter object writing data via `zipFileWriter`, adds the entry
// "hello.txt" containing the text "Hello world!" via `helloWorldReader`, and
// closes the writer.
const zipWriter = new ZipWriter(zipFileWriter);
await zipWriter.add("hello.txt", helloWorldReader);
await zipWriter.close();
// Retrieves the Blob object containing the zip content into `zipFileBlob`. It
// is also returned by zipWriter.close() for more convenience.
const zipFileBlob = await zipFileWriter.getData();
const zipFile = await Deno.open("some.zip", { create: true, write: true });
await zipFileBlob.stream().pipeTo(zipFile.writable);
console.log("Done!");Notice how the message is printed, but something is hanging the process to exit. Do I need to close something? I do not know what is happening here. Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
gildas-lormeau
Oct 17, 2025
Replies: 1 comment 1 reply
-
|
You have to call
import { BlobWriter, TextReader, ZipWriter, terminateWorkers } from "jsr:@zip-js/zip-js";
try {
// ...
} finally {
await terminateWorkers();
}
import { BlobWriter, TextReader, ZipWriter, configure } from "jsr:@zip-js/zip-js";
configure({ terminateWorkerTimeout: 0 }); // no delay
// ... |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
gildas-lormeau
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to call
await zip.terminateWorkers()or reduce the termination delay of web workers (5s by default) by callingzip.configure({ terminateWorkerTimeout: delay }).await terminateWorkers()configure({ terminateWorkerTimeout: delay })