◐ Shell
clean mode source ↗

fs: lazily load ReadFileContext · nodejs/node@3a55bd9

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