4
4
ArrayPrototypePush,
5
5
ArrayPrototypePop,
6
6
Error,
7
+ ErrorCaptureStackTrace,
7
8
MathMax,
8
9
MathMin,
9
10
NumberIsSafeInteger,
@@ -138,6 +139,15 @@ function lazyFsStreams() {
138
139
139
140
const lazyRimRaf = getLazy ( ( ) => require ( 'internal/fs/rimraf' ) . rimrafPromises ) ;
140
141
142
+ // By the time the C++ land creates an error for a promise rejection (likely from a
143
+ // libuv callback), there is already no JS frames on the stack. So we need to
144
+ // wait until V8 resumes execution back to JS land before we have enough information
145
+ // to re-capture the stack trace.
146
+ function handleErrorFromBinding ( error ) {
147
+ ErrorCaptureStackTrace ( error , handleErrorFromBinding ) ;
148
+ return PromiseReject ( error ) ;
149
+ }
150
+
141
151
class FileHandle extends EventEmitterMixin ( JSTransferable ) {
142
152
/**
143
153
* @param {InternalFSBinding.FileHandle | undefined } filehandle
@@ -502,7 +512,11 @@ async function readFileHandle(filehandle, options) {
502
512
503
513
checkAborted ( signal ) ;
504
514
505
- const statFields = await binding . fstat ( filehandle . fd , false , kUsePromises ) ;
515
+ const statFields = await PromisePrototypeThen (
516
+ binding . fstat ( filehandle . fd , false , kUsePromises ) ,
517
+ undefined ,
518
+ handleErrorFromBinding ,
519
+ ) ;
506
520
507
521
checkAborted ( signal ) ;
508
522
@@ -533,8 +547,11 @@ async function readFileHandle(filehandle, options) {
533
547
length = MathMin ( size - totalRead , kReadFileBufferLength ) ;
534
548
}
535
549
536
- const bytesRead = ( await binding . read ( filehandle . fd , buffer , offset ,
537
- length , - 1 , kUsePromises ) ) ?? 0 ;
550
+ const bytesRead = ( await PromisePrototypeThen (
551
+ binding . read ( filehandle . fd , buffer , offset , length , - 1 , kUsePromises ) ,
552
+ undefined ,
553
+ handleErrorFromBinding ,
554
+ ) ) ?? 0 ;
538
555
totalRead += bytesRead ;
539
556
540
557
if ( bytesRead === 0 ||
@@ -582,8 +599,11 @@ async function access(path, mode = F_OK) {
582
599
path = getValidatedPath ( path ) ;
583
600
584
601
mode = getValidMode ( mode , 'access' ) ;
585
- return binding . access ( pathModule . toNamespacedPath ( path ) , mode ,
586
- kUsePromises ) ;
602
+ return await PromisePrototypeThen (
603
+ binding . access ( pathModule . toNamespacedPath ( path ) , mode , kUsePromises ) ,
604
+ undefined ,
605
+ handleErrorFromBinding ,
606
+ ) ;
587
607
}
588
608
589
609
async function cp ( src , dest , options ) {
@@ -597,10 +617,14 @@ async function copyFile(src, dest, mode) {
597
617
src = getValidatedPath ( src , 'src' ) ;
598
618
dest = getValidatedPath ( dest , 'dest' ) ;
599
619
mode = getValidMode ( mode , 'copyFile' ) ;
600
- return binding . copyFile ( pathModule . toNamespacedPath ( src ) ,
601
- pathModule . toNamespacedPath ( dest ) ,
602
- mode ,
603
- kUsePromises ) ;
620
+ return await PromisePrototypeThen (
621
+ binding . copyFile ( pathModule . toNamespacedPath ( src ) ,
622
+ pathModule . toNamespacedPath ( dest ) ,
623
+ mode ,
624
+ kUsePromises ) ,
625
+ undefined ,
626
+ handleErrorFromBinding ,
627
+ ) ;
604
628
}
605
629
606
630
// Note that unlike fs.open() which uses numeric file descriptors,
@@ -609,9 +633,12 @@ async function open(path, flags, mode) {
609
633
path = getValidatedPath ( path ) ;
610
634
const flagsNumber = stringToFlags ( flags ) ;
611
635
mode = parseFileMode ( mode , 'mode' , 0o666 ) ;
612
- return new FileHandle (
613
- await binding . openFileHandle ( pathModule . toNamespacedPath ( path ) ,
614
- flagsNumber , mode , kUsePromises ) ) ;
636
+ return new FileHandle ( await PromisePrototypeThen (
637
+ binding . openFileHandle ( pathModule . toNamespacedPath ( path ) ,
638
+ flagsNumber , mode , kUsePromises ) ,
639
+ undefined ,
640
+ handleErrorFromBinding ,
641
+ ) ) ;
615
642
}
616
643
617
644
async function read ( handle , bufferOrParams , offset , length , position ) {
@@ -661,8 +688,11 @@ async function read(handle, bufferOrParams, offset, length, position) {
661
688
if ( ! NumberIsSafeInteger ( position ) )
662
689
position = - 1 ;
663
690
664
- const bytesRead = ( await binding . read ( handle . fd , buffer , offset , length ,
665
- position , kUsePromises ) ) || 0 ;
691
+ const bytesRead = ( await PromisePrototypeThen (
692
+ binding . read ( handle . fd , buffer , offset , length , position , kUsePromises ) ,
693
+ undefined ,
694
+ handleErrorFromBinding ,
695
+ ) ) || 0 ;
666
696
667
697
return { __proto__ : null , bytesRead, buffer } ;
668
698
}
@@ -673,8 +703,11 @@ async function readv(handle, buffers, position) {
673
703
if ( typeof position !== 'number' )
674
704
position = null ;
675
705
676
- const bytesRead = ( await binding . readBuffers ( handle . fd , buffers , position ,
677
- kUsePromises ) ) || 0 ;
706
+ const bytesRead = ( await PromisePrototypeThen (
707
+ binding . readBuffers ( handle . fd , buffers , position , kUsePromises ) ,
708
+ undefined ,
709
+ handleErrorFromBinding ,
710
+ ) ) || 0 ;
678
711
return { __proto__ : null , bytesRead, buffers } ;
679
712
}
680
713
@@ -703,15 +736,22 @@ async function write(handle, buffer, offsetOrOptions, length, position) {
703
736
position = null ;
704
737
validateOffsetLengthWrite ( offset , length , buffer . byteLength ) ;
705
738
const bytesWritten =
706
- ( await binding . writeBuffer ( handle . fd , buffer , offset ,
707
- length , position , kUsePromises ) ) || 0 ;
739
+ ( await PromisePrototypeThen (
740
+ binding . writeBuffer ( handle . fd , buffer , offset ,
741
+ length , position , kUsePromises ) ,
742
+ undefined ,
743
+ handleErrorFromBinding ,
744
+ ) ) || 0 ;
708
745
return { __proto__ : null , bytesWritten, buffer } ;
709
746
}
710
747
711
748
validateStringAfterArrayBufferView ( buffer , 'buffer' ) ;
712
749
validateEncoding ( buffer , length ) ;
713
- const bytesWritten = ( await binding . writeString ( handle . fd , buffer , offset ,
714
- length , kUsePromises ) ) || 0 ;
750
+ const bytesWritten = ( await PromisePrototypeThen (
751
+ binding . writeString ( handle . fd , buffer , offset , length , kUsePromises ) ,
752
+ undefined ,
753
+ handleErrorFromBinding ,
754
+ ) ) || 0 ;
715
755
return { __proto__ : null , bytesWritten, buffer } ;
716
756
}
717
757
@@ -725,17 +765,24 @@ async function writev(handle, buffers, position) {
725
765
return { __proto__ : null , bytesWritten : 0 , buffers } ;
726
766
}
727
767
728
- const bytesWritten = ( await binding . writeBuffers ( handle . fd , buffers , position ,
729
- kUsePromises ) ) || 0 ;
768
+ const bytesWritten = ( await PromisePrototypeThen (
769
+ binding . writeBuffers ( handle . fd , buffers , position , kUsePromises ) ,
770
+ undefined ,
771
+ handleErrorFromBinding ,
772
+ ) ) || 0 ;
730
773
return { __proto__ : null , bytesWritten, buffers } ;
731
774
}
732
775
733
776
async function rename ( oldPath , newPath ) {
734
777
oldPath = getValidatedPath ( oldPath , 'oldPath' ) ;
735
778
newPath = getValidatedPath ( newPath , 'newPath' ) ;
736
- return binding . rename ( pathModule . toNamespacedPath ( oldPath ) ,
737
- pathModule . toNamespacedPath ( newPath ) ,
738
- kUsePromises ) ;
779
+ return await PromisePrototypeThen (
780
+ binding . rename ( pathModule . toNamespacedPath ( oldPath ) ,
781
+ pathModule . toNamespacedPath ( newPath ) ,
782
+ kUsePromises ) ,
783
+ undefined ,
784
+ handleErrorFromBinding ,
785
+ ) ;
739
786
}
740
787
741
788
async function truncate ( path , len = 0 ) {
@@ -746,7 +793,11 @@ async function truncate(path, len = 0) {
746
793
async function ftruncate ( handle , len = 0 ) {
747
794
validateInteger ( len , 'len' ) ;
748
795
len = MathMax ( 0 , len ) ;
749
- return binding . ftruncate ( handle . fd , len , kUsePromises ) ;
796
+ return await PromisePrototypeThen (
797
+ binding . ftruncate ( handle . fd , len , kUsePromises ) ,
798
+ undefined ,
799
+ handleErrorFromBinding ,
800
+ ) ;
750
801
}
751
802
752
803
async function rm ( path , options ) {
@@ -767,15 +818,27 @@ async function rmdir(path, options) {
767
818
}
768
819
}
769
820
770
- return binding . rmdir ( path , kUsePromises ) ;
821
+ return await PromisePrototypeThen (
822
+ binding . rmdir ( path , kUsePromises ) ,
823
+ undefined ,
824
+ handleErrorFromBinding ,
825
+ ) ;
771
826
}
772
827
773
828
async function fdatasync ( handle ) {
774
- return binding . fdatasync ( handle . fd , kUsePromises ) ;
829
+ return await PromisePrototypeThen (
830
+ binding . fdatasync ( handle . fd , kUsePromises ) ,
831
+ undefined ,
832
+ handleErrorFromBinding ,
833
+ ) ;
775
834
}
776
835
777
836
async function fsync ( handle ) {
778
- return binding . fsync ( handle . fd , kUsePromises ) ;
837
+ return await PromisePrototypeThen (
838
+ binding . fsync ( handle . fd , kUsePromises ) ,
839
+ undefined ,
840
+ handleErrorFromBinding ,
841
+ ) ;
779
842
}
780
843
781
844
async function mkdir ( path , options ) {
@@ -789,21 +852,29 @@ async function mkdir(path, options) {
789
852
path = getValidatedPath ( path ) ;
790
853
validateBoolean ( recursive , 'options.recursive' ) ;
791
854
792
- return binding . mkdir ( pathModule . toNamespacedPath ( path ) ,
793
- parseFileMode ( mode , 'mode' , 0o777 ) , recursive ,
794
- kUsePromises ) ;
855
+ return await PromisePrototypeThen (
856
+ binding . mkdir ( pathModule . toNamespacedPath ( path ) ,
857
+ parseFileMode ( mode , 'mode' , 0o777 ) , recursive ,
858
+ kUsePromises ) ,
859
+ undefined ,
860
+ handleErrorFromBinding ,
861
+ ) ;
795
862
}
796
863
797
864
async function readdirRecursive ( originalPath , options ) {
798
865
const result = [ ] ;
799
866
const queue = [
800
867
[
801
868
originalPath ,
802
- await binding . readdir (
803
- pathModule . toNamespacedPath ( originalPath ) ,
804
- options . encoding ,
805
- ! ! options . withFileTypes ,
806
- kUsePromises ,
869
+ await PromisePrototypeThen (
870
+ binding . readdir (
871
+ pathModule . toNamespacedPath ( originalPath ) ,
872
+ options . encoding ,
873
+ ! ! options . withFileTypes ,
874
+ kUsePromises ,
875
+ ) ,
876
+ undefined ,
877
+ handleErrorFromBinding ,
807
878
) ,
808
879
] ,
809
880
] ;
@@ -819,11 +890,15 @@ async function readdirRecursive(originalPath, options) {
819
890
const direntPath = pathModule . join ( path , dirent . name ) ;
820
891
ArrayPrototypePush ( queue , [
821
892
direntPath ,
822
- await binding . readdir (
823
- direntPath ,
824
- options . encoding ,
825
- true ,
826
- kUsePromises ,
893
+ await PromisePrototypeThen (
894
+ binding . readdir (
895
+ direntPath ,
896
+ options . encoding ,
897
+ true ,
898
+ kUsePromises ,
899
+ ) ,
900
+ undefined ,
901
+ handleErrorFromBinding ,
827
902
) ,
828
903
] ) ;
829
904
}
@@ -842,11 +917,15 @@ async function readdirRecursive(originalPath, options) {
842
917
if ( stat === 1 ) {
843
918
ArrayPrototypePush ( queue , [
844
919
direntPath ,
845
- await binding . readdir (
846
- pathModule . toNamespacedPath ( direntPath ) ,
847
- options . encoding ,
848
- false ,
849
- kUsePromises ,
920
+ await PromisePrototypeThen (
921
+ binding . readdir (
922
+ pathModule . toNamespacedPath ( direntPath ) ,
923
+ options . encoding ,
924
+ false ,
925
+ kUsePromises ,
926
+ ) ,
927
+ undefined ,
928
+ handleErrorFromBinding ,
850
929
) ,
851
930
] ) ;
852
931
}
@@ -863,11 +942,15 @@ async function readdir(path, options) {
863
942
if ( options . recursive ) {
864
943
return readdirRecursive ( path , options ) ;
865
944
}
866
- const result = await binding . readdir (
867
- pathModule . toNamespacedPath ( path ) ,
868
- options . encoding ,
869
- ! ! options . withFileTypes ,
870
- kUsePromises ,
945
+ const result = await PromisePrototypeThen (
946
+ binding . readdir (
947
+ pathModule . toNamespacedPath ( path ) ,
948
+ options . encoding ,
949
+ ! ! options . withFileTypes ,
950
+ kUsePromises ,
951
+ ) ,
952
+ undefined ,
953
+ handleErrorFromBinding ,
871
954
) ;
872
955
return options . withFileTypes ?
873
956
getDirectoryEntriesPromise ( path , result ) :
@@ -877,8 +960,12 @@ async function readdir(path, options) {
877
960
async function readlink ( path , options ) {
878
961
options = getOptions ( options ) ;
879
962
path = getValidatedPath ( path , 'oldPath' ) ;
880
- return binding . readlink ( pathModule . toNamespacedPath ( path ) ,
881
- options . encoding , kUsePromises ) ;
963
+ return await PromisePrototypeThen (
964
+ binding . readlink ( pathModule . toNamespacedPath ( path ) ,
965
+ options . encoding , kUsePromises ) ,
966
+ undefined ,
967
+ handleErrorFromBinding ,
968
+ ) ;
882
969
}
883
970
884
971
async function symlink ( target , path , type_ ) {
@@ -903,60 +990,96 @@ async function symlink(target, path, type_) {
903
990
904
991
target = getValidatedPath ( target , 'target' ) ;
905
992
path = getValidatedPath ( path ) ;
906
- return binding . symlink ( preprocessSymlinkDestination ( target , type , path ) ,
907
- pathModule . toNamespacedPath ( path ) ,
908
- stringToSymlinkType ( type ) ,
909
- kUsePromises ) ;
993
+ return await PromisePrototypeThen (
994
+ binding . symlink ( preprocessSymlinkDestination ( target , type , path ) ,
995
+ pathModule . toNamespacedPath ( path ) ,
996
+ stringToSymlinkType ( type ) ,
997
+ kUsePromises ) ,
998
+ undefined ,
999
+ handleErrorFromBinding ,
1000
+ ) ;
910
1001
}
911
1002
912
1003
async function fstat ( handle , options = { bigint : false } ) {
913
- const result = await binding . fstat ( handle . fd , options . bigint , kUsePromises ) ;
1004
+ const result = await PromisePrototypeThen (
1005
+ binding . fstat ( handle . fd , options . bigint , kUsePromises ) ,
1006
+ undefined ,
1007
+ handleErrorFromBinding ,
1008
+ ) ;
914
1009
return getStatsFromBinding ( result ) ;
915
1010
}
916
1011
917
1012
async function lstat ( path , options = { bigint : false } ) {
918
1013
path = getValidatedPath ( path ) ;
919
- const result = await binding . lstat ( pathModule . toNamespacedPath ( path ) ,
920
- options . bigint , kUsePromises ) ;
1014
+ const result = await PromisePrototypeThen (
1015
+ binding . lstat ( pathModule . toNamespacedPath ( path ) ,
1016
+ options . bigint , kUsePromises ) ,
1017
+ undefined ,
1018
+ handleErrorFromBinding ,
1019
+ ) ;
921
1020
return getStatsFromBinding ( result ) ;
922
1021
}
923
1022
924
1023
async function stat ( path , options = { bigint : false } ) {
925
1024
path = getValidatedPath ( path ) ;
926
- const result = await binding . stat ( pathModule . toNamespacedPath ( path ) ,
927
- options . bigint , kUsePromises ) ;
1025
+ const result = await PromisePrototypeThen (
1026
+ binding . stat ( pathModule . toNamespacedPath ( path ) ,
1027
+ options . bigint , kUsePromises ) ,
1028
+ undefined ,
1029
+ handleErrorFromBinding ,
1030
+ ) ;
928
1031
return getStatsFromBinding ( result ) ;
929
1032
}
930
1033
931
1034
async function statfs ( path , options = { bigint : false } ) {
932
1035
path = getValidatedPath ( path ) ;
933
- const result = await binding . statfs ( pathModule . toNamespacedPath ( path ) ,
934
- options . bigint , kUsePromises ) ;
1036
+ const result = await PromisePrototypeThen (
1037
+ binding . statfs ( pathModule . toNamespacedPath ( path ) ,
1038
+ options . bigint , kUsePromises ) ,
1039
+ undefined ,
1040
+ handleErrorFromBinding ,
1041
+ ) ;
935
1042
return getStatFsFromBinding ( result ) ;
936
1043
}
937
1044
938
1045
async function link ( existingPath , newPath ) {
939
1046
existingPath = getValidatedPath ( existingPath , 'existingPath' ) ;
940
1047
newPath = getValidatedPath ( newPath , 'newPath' ) ;
941
- return binding . link ( pathModule . toNamespacedPath ( existingPath ) ,
942
- pathModule . toNamespacedPath ( newPath ) ,
943
- kUsePromises ) ;
1048
+ return await PromisePrototypeThen (
1049
+ binding . link ( pathModule . toNamespacedPath ( existingPath ) ,
1050
+ pathModule . toNamespacedPath ( newPath ) ,
1051
+ kUsePromises ) ,
1052
+ undefined ,
1053
+ handleErrorFromBinding ,
1054
+ ) ;
944
1055
}
945
1056
946
1057
async function unlink ( path ) {
947
1058
path = getValidatedPath ( path ) ;
948
- return binding . unlink ( pathModule . toNamespacedPath ( path ) , kUsePromises ) ;
1059
+ return await PromisePrototypeThen (
1060
+ binding . unlink ( pathModule . toNamespacedPath ( path ) , kUsePromises ) ,
1061
+ undefined ,
1062
+ handleErrorFromBinding ,
1063
+ ) ;
949
1064
}
950
1065
951
1066
async function fchmod ( handle , mode ) {
952
1067
mode = parseFileMode ( mode , 'mode' ) ;
953
- return binding . fchmod ( handle . fd , mode , kUsePromises ) ;
1068
+ return await PromisePrototypeThen (
1069
+ binding . fchmod ( handle . fd , mode , kUsePromises ) ,
1070
+ undefined ,
1071
+ handleErrorFromBinding ,
1072
+ ) ;
954
1073
}
955
1074
956
1075
async function chmod ( path , mode ) {
957
1076
path = getValidatedPath ( path ) ;
958
1077
mode = parseFileMode ( mode , 'mode' ) ;
959
- return binding . chmod ( pathModule . toNamespacedPath ( path ) , mode , kUsePromises ) ;
1078
+ return await PromisePrototypeThen (
1079
+ binding . chmod ( pathModule . toNamespacedPath ( path ) , mode , kUsePromises ) ,
1080
+ undefined ,
1081
+ handleErrorFromBinding ,
1082
+ ) ;
960
1083
}
961
1084
962
1085
async function lchmod ( path , mode ) {
@@ -971,50 +1094,76 @@ async function lchown(path, uid, gid) {
971
1094
path = getValidatedPath ( path ) ;
972
1095
validateInteger ( uid , 'uid' , - 1 , kMaxUserId ) ;
973
1096
validateInteger ( gid , 'gid' , - 1 , kMaxUserId ) ;
974
- return binding . lchown ( pathModule . toNamespacedPath ( path ) ,
975
- uid , gid , kUsePromises ) ;
1097
+ return await PromisePrototypeThen (
1098
+ binding . lchown ( pathModule . toNamespacedPath ( path ) , uid , gid , kUsePromises ) ,
1099
+ undefined ,
1100
+ handleErrorFromBinding ,
1101
+ ) ;
976
1102
}
977
1103
978
1104
async function fchown ( handle , uid , gid ) {
979
1105
validateInteger ( uid , 'uid' , - 1 , kMaxUserId ) ;
980
1106
validateInteger ( gid , 'gid' , - 1 , kMaxUserId ) ;
981
- return binding . fchown ( handle . fd , uid , gid , kUsePromises ) ;
1107
+ return await PromisePrototypeThen (
1108
+ binding . fchown ( handle . fd , uid , gid , kUsePromises ) ,
1109
+ undefined ,
1110
+ handleErrorFromBinding ,
1111
+ ) ;
982
1112
}
983
1113
984
1114
async function chown ( path , uid , gid ) {
985
1115
path = getValidatedPath ( path ) ;
986
1116
validateInteger ( uid , 'uid' , - 1 , kMaxUserId ) ;
987
1117
validateInteger ( gid , 'gid' , - 1 , kMaxUserId ) ;
988
- return binding . chown ( pathModule . toNamespacedPath ( path ) ,
989
- uid , gid , kUsePromises ) ;
1118
+ return await PromisePrototypeThen (
1119
+ binding . chown ( pathModule . toNamespacedPath ( path ) , uid , gid , kUsePromises ) ,
1120
+ undefined ,
1121
+ handleErrorFromBinding ,
1122
+ ) ;
990
1123
}
991
1124
992
1125
async function utimes ( path , atime , mtime ) {
993
1126
path = getValidatedPath ( path ) ;
994
- return binding . utimes ( pathModule . toNamespacedPath ( path ) ,
995
- toUnixTimestamp ( atime ) ,
996
- toUnixTimestamp ( mtime ) ,
997
- kUsePromises ) ;
1127
+ return await PromisePrototypeThen (
1128
+ binding . utimes ( pathModule . toNamespacedPath ( path ) ,
1129
+ toUnixTimestamp ( atime ) ,
1130
+ toUnixTimestamp ( mtime ) ,
1131
+ kUsePromises ) ,
1132
+ undefined ,
1133
+ handleErrorFromBinding ,
1134
+ ) ;
998
1135
}
999
1136
1000
1137
async function futimes ( handle , atime , mtime ) {
1001
1138
atime = toUnixTimestamp ( atime , 'atime' ) ;
1002
1139
mtime = toUnixTimestamp ( mtime , 'mtime' ) ;
1003
- return binding . futimes ( handle . fd , atime , mtime , kUsePromises ) ;
1140
+ return await PromisePrototypeThen (
1141
+ binding . futimes ( handle . fd , atime , mtime , kUsePromises ) ,
1142
+ undefined ,
1143
+ handleErrorFromBinding ,
1144
+ ) ;
1004
1145
}
1005
1146
1006
1147
async function lutimes ( path , atime , mtime ) {
1007
1148
path = getValidatedPath ( path ) ;
1008
- return binding . lutimes ( pathModule . toNamespacedPath ( path ) ,
1009
- toUnixTimestamp ( atime ) ,
1010
- toUnixTimestamp ( mtime ) ,
1011
- kUsePromises ) ;
1149
+ return await PromisePrototypeThen (
1150
+ binding . lutimes ( pathModule . toNamespacedPath ( path ) ,
1151
+ toUnixTimestamp ( atime ) ,
1152
+ toUnixTimestamp ( mtime ) ,
1153
+ kUsePromises ) ,
1154
+ undefined ,
1155
+ handleErrorFromBinding ,
1156
+ ) ;
1012
1157
}
1013
1158
1014
1159
async function realpath ( path , options ) {
1015
1160
options = getOptions ( options ) ;
1016
1161
path = getValidatedPath ( path ) ;
1017
- return binding . realpath ( pathModule . toNamespacedPath ( path ) , options . encoding , kUsePromises ) ;
1162
+ return await PromisePrototypeThen (
1163
+ binding . realpath ( pathModule . toNamespacedPath ( path ) , options . encoding , kUsePromises ) ,
1164
+ undefined ,
1165
+ handleErrorFromBinding ,
1166
+ ) ;
1018
1167
}
1019
1168
1020
1169
async function mkdtemp ( prefix , options ) {
@@ -1030,7 +1179,11 @@ async function mkdtemp(prefix, options) {
1030
1179
path = Buffer . concat ( [ prefix , Buffer . from ( 'XXXXXX' ) ] ) ;
1031
1180
}
1032
1181
1033
- return binding . mkdtemp ( path , options . encoding , kUsePromises ) ;
1182
+ return await PromisePrototypeThen (
1183
+ binding . mkdtemp ( path , options . encoding , kUsePromises ) ,
1184
+ undefined ,
1185
+ handleErrorFromBinding ,
1186
+ ) ;
1034
1187
}
1035
1188
1036
1189
async function writeFile ( path , data , options ) {
0 commit comments