@@ -15,6 +15,7 @@ const {
1515 MathMin,
1616 NumberIsSafeInteger,
1717 Promise,
18+ PromisePrototypeFinally,
1819 PromiseResolve,
1920 Symbol,
2021 Uint8Array,
@@ -410,7 +411,7 @@ async function rename(oldPath, newPath) {
410411
411412async function truncate ( path , len = 0 ) {
412413 const fd = await open ( path , 'r+' ) ;
413- return ftruncate ( fd , len ) . finally ( fd . close ) ;
414+ return PromisePrototypeFinally ( ftruncate ( fd , len ) , fd . close ) ;
414415}
415416
416417async function ftruncate ( handle , len = 0 ) {
@@ -538,7 +539,7 @@ async function lchmod(path, mode) {
538539 throw new ERR_METHOD_NOT_IMPLEMENTED ( 'lchmod()' ) ;
539540
540541 const fd = await open ( path , O_WRONLY | O_SYMLINK ) ;
541- return fchmod ( fd , mode ) . finally ( fd . close ) ;
542+ return PromisePrototypeFinally ( fchmod ( fd , mode ) , fd . close ) ;
542543}
543544
544545async function lchown ( path , uid , gid ) {
@@ -614,7 +615,7 @@ async function writeFile(path, data, options) {
614615 return writeFileHandle ( path , data ) ;
615616
616617 const fd = await open ( path , flag , options . mode ) ;
617- return writeFileHandle ( fd , data ) . finally ( fd . close ) ;
618+ return PromisePrototypeFinally ( writeFileHandle ( fd , data ) , fd . close ) ;
618619}
619620
620621async function appendFile ( path , data , options ) {
@@ -632,7 +633,7 @@ async function readFile(path, options) {
632633 return readFileHandle ( path , options ) ;
633634
634635 const fd = await open ( path , flag , 0o666 ) ;
635- return readFileHandle ( fd , options ) . finally ( fd . close ) ;
636+ return PromisePrototypeFinally ( readFileHandle ( fd , options ) , fd . close ) ;
636637}
637638
638639module . exports = {
0 commit comments