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

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎lib/internal/fs/promises.js‎

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

266266
asyncfunctiontruncate(path,len=0){
267-
returnftruncate(awaitopen(path,'r+'),len);
267+
constfd=awaitopen(path,'r+');
268+
returnftruncate(fd,len).finally(fd.close.bind(fd));
268269
}
269270

270271
asyncfunctionftruncate(handle,len=0){

0 commit comments

Comments
 (0)