Skip to content

Commit

Permalink
Fix tokenizer closure
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Jan 26, 2025
1 parent ab710a0 commit 4322df9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ const debug = initDebug('music-metadata:parser');
*/
export async function parseStream(stream: Readable, fileInfo?: IFileInfo | string, options: IOptions = {}): Promise<IAudioMetadata> {
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();
}
}

/**
Expand Down

0 comments on commit 4322df9

Please sign in to comment.