From 4322df92d83fb56408762f2648c369b66f79b280 Mon Sep 17 00:00:00 2001 From: Borewit Date: Sun, 26 Jan 2025 18:17:55 +0100 Subject: [PATCH] Fix tokenizer closure --- lib/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/index.ts b/lib/index.ts index 667e125b9..86bdbb702 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -23,7 +23,12 @@ const debug = initDebug('music-metadata:parser'); */ export async function parseStream(stream: Readable, fileInfo?: IFileInfo | string, options: IOptions = {}): Promise { const tokenizer = await fromStream(stream, {fileInfo: typeof fileInfo === 'string' ? {mimeType: fileInfo} : fileInfo}); - return parseFromTokenizer(tokenizer, options); + try { + return await parseFromTokenizer(tokenizer, options); + } + finally { + await tokenizer.close(); + } } /**