Garbage colleciton fix
All checks were successful
Publish Library / Build NPM Project (push) Successful in 12s
Publish Library / Tag Version (push) Successful in 10s

This commit is contained in:
2026-08-22 17:57:19 -04:00
parent d10ee1d686
commit 96ddcbe67a
3 changed files with 15 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@ztimson/zim-utils",
"version": "0.2.2",
"version": "0.2.3",
"description": "Native, dependency-light ZIM archive reader/searcher and Kiwix catalog downloader for Node.js",
"author": "Zak Timson",
"license": "MIT",

View File

@@ -169,8 +169,12 @@ export class ZimManager {
pending = new ZimReader(file, {clusterTTL: this.#clusterTTL}).open();
this.#opening.set(file, pending);
}
const reader = await pending;
this.#opening.delete(file);
let reader;
try {
reader = await pending;
} finally {
this.#opening.delete(file);
}
entry = this.#readers.get(file) ?? {reader};
this.#readers.set(file, entry);
}

View File

@@ -294,8 +294,14 @@ export class ZimReader {
/** Opens the archive and parses its header + mimetype list. */
async open() {
this.#fd = await fs.promises.open(this.path, 'r');
await this.#readHeader();
await this.#readMimeTypes();
try {
await this.#readHeader();
await this.#readMimeTypes();
} catch (e) {
await this.#fd.close();
this.#fd = null;
throw e;
}
return this;
}