Skip to content

Commit 1f7fac7

Browse files
committed
fix(transcripts): await read stream close after destroy
stream.destroy() starts async teardown but returns immediately, so the fd could still be open when the method rethrows. Wait for the 'close' event when the stream is not already closed to ensure the descriptor is released before the caller handles the rejection.
1 parent f6e7dd1 commit 1f7fac7

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/transcripts/store.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ export class TranscriptsStore {
215215
} finally {
216216
lines.close();
217217
stream.destroy();
218+
if (!stream.closed) {
219+
await new Promise<void>((resolve) => {
220+
stream.once("close", resolve);
221+
});
222+
}
218223
}
219224
} catch (err) {
220225
if (err && typeof err === "object" && "code" in err && err.code === "ENOENT") {

0 commit comments

Comments
 (0)