Skip to content

Commit 643f4f3

Browse files
gurgundaynodejs-github-bot
authored andcommitted
fs: lazily load ReadFileContext
PR-URL: nodejs#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 f58d5be commit 643f4f3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/fs.js

Lines changed: 2 additions & 1 deletion
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)