Skip to content

Commit 3a55bd9

Browse files
gurgundayruyadorno
authored andcommitted
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 bb4aa7a commit 3a55bd9

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
@@ -162,6 +162,7 @@ let WriteStream;
162162
let rimraf;
163163
let rimrafSync;
164164
let kResistStopPropagation;
165+
let ReadFileContext;
165166

166167
// These have to be separate because of how graceful-fs happens to do it's
167168
// monkeypatching.
@@ -363,7 +364,7 @@ function readFile(path, options, callback) {
363364
callback ||= options;
364365
validateFunction(callback, 'cb');
365366
options = getOptions(options, { flag: 'r' });
366-
const ReadFileContext = require('internal/fs/read/context');
367+
ReadFileContext ??= require('internal/fs/read/context');
367368
const context = new ReadFileContext(callback, options.encoding);
368369
context.isUserFd = isFd(path); // File descriptor ownership
369370

0 commit comments

Comments
 (0)