@@ -66,6 +66,7 @@ const {
66
66
const { opendir } = require ( 'internal/fs/dir' ) ;
67
67
const {
68
68
parseFileMode,
69
+ validateAbortSignal,
69
70
validateBoolean,
70
71
validateBuffer,
71
72
validateInteger,
@@ -668,13 +669,15 @@ async function writeFile(path, data, options) {
668
669
data = Buffer . from ( data , options . encoding || 'utf8' ) ;
669
670
}
670
671
672
+ validateAbortSignal ( options . signal ) ;
671
673
if ( path instanceof FileHandle )
672
674
return writeFileHandle ( path , data , options . signal ) ;
673
675
674
- const fd = await open ( path , flag , options . mode ) ;
675
676
if ( options . signal ?. aborted ) {
676
677
throw lazyDOMException ( 'The operation was aborted' , 'AbortError' ) ;
677
678
}
679
+
680
+ const fd = await open ( path , flag , options . mode ) ;
678
681
return PromisePrototypeFinally ( writeFileHandle ( fd , data ) , fd . close ) ;
679
682
}
680
683
@@ -692,6 +695,10 @@ async function readFile(path, options) {
692
695
if ( path instanceof FileHandle )
693
696
return readFileHandle ( path , options ) ;
694
697
698
+ if ( options . signal ?. aborted ) {
699
+ throw lazyDOMException ( 'The operation was aborted' , 'AbortError' ) ;
700
+ }
701
+
695
702
const fd = await open ( path , flag , 0o666 ) ;
696
703
return PromisePrototypeFinally ( readFileHandle ( fd , options ) , fd . close ) ;
697
704
}
0 commit comments