Skip to content

Commit 04fa6d6

Browse files
joaocgreisjasnell
authored andcommitted
fs: close file descriptor of promisified truncate
Original PR: PR-URL: #28858 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> PR-URL: #34239 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
1 parent d547d1c commit 04fa6d6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/internal/fs/promises.js

+2-1
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)