Skip to content

src: throw error in LoadBuiltinModuleSource when reading fails

  • Move the file reading code in LoadBuiltinModuleSource into util.h so that it can be reused by other C++ code, and return an error code from it when there is a failure for the caller to generate an error.
  • Throw an error when reading local builtins fails in LoadBulitinModuleSource.

The error looks something like this

node:internal/bootstrap/loaders:311
      const fn = compileFunction(id);
                 ^

Error: Cannot read local builtin. ENOENT: no such file or directory "/Users/joyee/projects/node/lib/fs.js"
    at NativeModule.compileForInternalLoader (node:internal/bootstrap/loaders:311:18)
    at nativeModuleRequire (node:internal/bootstrap/loaders:341:14)
    at node:internal/bootstrap/node:362:1

Merge request reports

Loading