Skip to content

Commit

Permalink
fs: lazily load ReadFileContext
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gurgunday authored and aduh95 committed Dec 13, 2024
1 parent a86f60a commit 933c54b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ let WriteStream;
let rimraf;
let rimrafSync;
let kResistStopPropagation;
let ReadFileContext;

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

Expand Down

0 comments on commit 933c54b

Please sign in to comment.