Deno found a memory leak #538
-
Hi! I would like to use zip.js library in my project. Function called in test: export const compressFiles = (
filesToCompress: File[],
name: string,
): ResultAsync<File, Error> => {
const zip = new ZipWriter(new BlobWriter("application/zip"));
const operations: ResultAsync<EntryMetaData, Error>[] = [];
filesToCompress.forEach((file) => {
operations.push(
ResultAsync.fromPromise(
zip.add(file.name, file.stream()),
(error) => ensureError(error),
),
);
});
return ResultAsync.combine(operations).andThen(() =>
ResultAsync.fromPromise(
zip.close(undefined),
(error) => ensureError(error),
)
.andThen((blob) => {
return okAsync(new File([blob], name, { type: "application/zip" }));
})
);
}; Test code: describe.only("test", () => {
it("should zip a file", async () => {
await Lufi.compressFiles([file117kb], "test.zip").andThen((file) => {
console.debug(file);
return okAsync(undefined);
});
});
}); Console logs Upload => https://jsr.io/@std/testing/1.0.3/_test_suite.ts:212:10
error: Leaks detected:
- A timer was started in this test, but never completed. This is often caused by not calling `clearTimeout`. The operation was started here:
at Object.queueUserTimer (ext:core/01_core.js:773:9)
at setTimeout (ext:deno_web/02_timers.js:74:15)
at Timeout.<computed> (ext:deno_node/internal/timers.mjs:68:7)
at new Timeout (ext:deno_node/internal/timers.mjs:55:37)
at setTimeout (node:timers:13:10)
at terminateWorker (file:///home/booteille/Dev/lufi-api/node_modules/.deno/@zip.js+zip.js@2.7.53/node_modules/@zip.js/zip.js/lib/core/codec-pool.js:102:34)
at onTaskFinished (file:///home/booteille/Dev/lufi-api/node_modules/.deno/@zip.js+zip.js@2.7.53/node_modules/@zip.js/zip.js/lib/core/codec-pool.js:88:4)
at onTaskFinished (file:///home/booteille/Dev/lufi-api/node_modules/.deno/@zip.js+zip.js@2.7.53/node_modules/@zip.js/zip.js/lib/core/codec-worker.js:91:5)
at close (file:///home/booteille/Dev/lufi-api/node_modules/.deno/@zip.js+zip.js@2.7.53/node_modules/@zip.js/zip.js/lib/core/codec-worker.js:346:3)
at onMessage (file:///home/booteille/Dev/lufi-api/node_modules/.deno/@zip.js+zip.js@2.7.53/node_modules/@zip.js/zip.js/lib/core/codec-worker.js:329:5) I guess there is an issue either with the library either with deno. Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
gildas-lormeau
Oct 31, 2024
Replies: 1 comment
-
You need to call |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
gildas-lormeau
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to call
await zip.terminateWorkers()
to stop the web workers used to compress data before the end of the execution.