Skip to content

Commit ece2edf

Browse files
committed
Fix missing file handle close if createWriteStream throws
Current versions of Node.js will actually close the file descriptor once the file handle object gets GC'd, though this is deprecated and ought not be relied on.
1 parent 9bcf45d commit ece2edf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src-main/atomic-write-stream.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ const createAtomicWriteStream = async (path) => {
142142
highWaterMark: 1024 * 1024 * 5
143143
});
144144
} catch (err) {
145+
if (fileHandle) {
146+
fileHandle.close();
147+
}
145148
releaseFileLock();
146149
throw err;
147150
}

0 commit comments

Comments
 (0)