Skip to content

Commit ba3a5e6

Browse files
gurgundaynodejs-github-bot
authored andcommittedDec 4, 2024
fs: lazily load ReadFileContext
PR-URL: nodejs#55998 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>
1 parent 0b8484d commit ba3a5e6

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)