Skip to content

Commit 2073a78

Browse files
joaocgreisjasnell
authored andcommitted
fs: close file descriptor of promisified truncate
PR-URL: nodejs/node#28858 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 83c9364 commit 2073a78

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/internal/fs/promises.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ async function rename(oldPath, newPath) {
305305
}
306306

307307
async function truncate(path, len = 0) {
308-
return ftruncate(await open(path, 'r+'), len);
308+
const fd = await open(path, 'r+');
309+
return ftruncate(fd, len).finally(fd.close.bind(fd));
309310
}
310311

311312
async function ftruncate(handle, len = 0) {

0 commit comments

Comments
 (0)