Skip to content

Commit a37e5fe

Browse files
gurgundaytargos
authored andcommitted
fs: lazily load ReadFileContext
PR-URL: #55998 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jason Zhang <[email protected]>
1 parent 99858ce commit a37e5fe

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/fs.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ let ReadStream;
163163
let WriteStream;
164164
let rimraf;
165165
let kResistStopPropagation;
166+
let ReadFileContext;
166167

167168
// These have to be separate because of how graceful-fs happens to do it's
168169
// monkeypatching.
@@ -364,7 +365,7 @@ function readFile(path, options, callback) {
364365
callback ||= options;
365366
validateFunction(callback, 'cb');
366367
options = getOptions(options, { flag: 'r' });
367-
const ReadFileContext = require('internal/fs/read/context');
368+
ReadFileContext ??= require('internal/fs/read/context');
368369
const context = new ReadFileContext(callback, options.encoding);
369370
context.isUserFd = isFd(path); // File descriptor ownership
370371

0 commit comments

Comments
 (0)