Skip to content

Commit ba912ee

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

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
@@ -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)