Skip to content

Commit 3a55bd9

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

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

Diff for: ‎lib/fs.js

+2-1
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)
Please sign in to comment.