Skip to content

Commit ba912ee

Browse files
authored
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 08e0147 commit ba912ee

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/fs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ let ReadStream;
164164
let WriteStream;
165165
let rimraf;
166166
let kResistStopPropagation;
167+
let ReadFileContext;
167168

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

0 commit comments

Comments
 (0)