From f6d411e99656d9387607e7956f0ba8640d7a3f7f Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Sat, 2 Dec 2023 15:42:53 +0900 Subject: [PATCH] fixed mem leak --- main.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.ts b/main.ts index d225350..523f61e 100644 --- a/main.ts +++ b/main.ts @@ -103,8 +103,6 @@ const options = { async run() { const db = await createDatabase(args.values.db!); const library = createLibrary(db); - const browser = await chromium.launch(); - const platform = createPlatform({ db, browser }); const books: Array = []; if (args.values.download === "all") { @@ -124,12 +122,13 @@ const options = { } for (const book of books) { + const browser = await chromium.launch(); + const platform = createPlatform({ db, browser }); const dir = `${args.values["out-dir"]!}/${book.id}`; await platform.download(dir, book); await library.archive(dir, args.values["out-dir"]!, book); + await browser.close(); } - - await browser.close(); }, }, json: {