Skip to content

Commit eadc385

Browse files
joaocgreisTrott
authored andcommitted
fs: close file descriptor of promisified truncate
PR-URL: #28858 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent d3f20a4 commit eadc385

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
@@ -264,7 +264,8 @@ async function rename(oldPath, newPath) {
264264
}
265265

266266
async function truncate(path, len = 0) {
267-
return ftruncate(await open(path, 'r+'), len);
267+
const fd = await open(path, 'r+');
268+
return ftruncate(fd, len).finally(fd.close.bind(fd));
268269
}
269270

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

0 commit comments

Comments
 (0)