Skip to content

Commit 9317feb

Browse files
gurgundaymarco-ippolito
authored andcommittedJan 24, 2025
fs: lazily load ReadFileContext
PR-URL: #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 6fc7328 commit 9317feb

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
@@ -159,6 +159,7 @@ let WriteStream;
159159
let rimraf;
160160
let rimrafSync;
161161
let kResistStopPropagation;
162+
let ReadFileContext;
162163

163164
// These have to be separate because of how graceful-fs happens to do it's
164165
// 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)
Please sign in to comment.