@@ -15,7 +15,10 @@ const {
15
15
16
16
const { Buffer } = require ( 'buffer' ) ;
17
17
18
- const { FSReqCallback, close, read } = internalBinding ( 'fs' ) ;
18
+ // It is important to not destructure the binding object, as it will
19
+ // cause the creation context to be undefined, and cause fast API calls
20
+ // to fail.
21
+ const binding = internalBinding ( 'fs' ) ;
19
22
20
23
const {
21
24
AbortError,
@@ -102,11 +105,11 @@ class ReadFileContext {
102
105
length = MathMin ( kReadFileBufferLength , this . size - this . pos ) ;
103
106
}
104
107
105
- const req = new FSReqCallback ( ) ;
108
+ const req = new binding . FSReqCallback ( ) ;
106
109
req . oncomplete = readFileAfterRead ;
107
110
req . context = this ;
108
111
109
- read ( this . fd , buffer , offset , length , - 1 , req ) ;
112
+ binding . read ( this . fd , buffer , offset , length , - 1 , req ) ;
110
113
}
111
114
112
115
close ( err ) {
@@ -117,12 +120,12 @@ class ReadFileContext {
117
120
return ;
118
121
}
119
122
120
- const req = new FSReqCallback ( ) ;
123
+ const req = new binding . FSReqCallback ( ) ;
121
124
req . oncomplete = readFileAfterClose ;
122
125
req . context = this ;
123
126
this . err = err ;
124
127
125
- close ( this . fd , req ) ;
128
+ binding . close ( this . fd , req ) ;
126
129
}
127
130
}
128
131
0 commit comments