Skip to content

Commit

Permalink
fs: lazily load ReadFileContext
Browse files Browse the repository at this point in the history
PR-URL: nodejs#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 nodejs-github-bot committed Dec 4, 2024
1 parent 3714e1e commit d57a16f
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 @@ -163,6 +163,7 @@ let ReadStream;
let WriteStream;
let rimraf;
let kResistStopPropagation;
let ReadFileContext;

// These have to be separate because of how graceful-fs happens to do it's
// monkeypatching.
Expand Down Expand Up @@ -364,7 +365,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 d57a16f

Please sign in to comment.