summaryrefslogtreecommitdiff
path: root/lib/internal/bootstrap/loaders.js
diff options
context:
space:
mode:
authorJeremiah Senkpiel <fishrock123@rocketmail.com>2019-09-17 12:45:23 -0700
committerRich Trott <rtrott@gmail.com>2019-09-18 08:18:38 -0700
commit4d798e1b1bbbbbf0a45fb478e153621fc37bb242 (patch)
tree9fc77ebed1b03a07e58707e38f85bd94ff828881 /lib/internal/bootstrap/loaders.js
parent9fb8b8d0f71e7576759e2b9ebf6f64403a336a13 (diff)
downloadandroid-node-v8-4d798e1b1bbbbbf0a45fb478e153621fc37bb242.tar.gz
android-node-v8-4d798e1b1bbbbbf0a45fb478e153621fc37bb242.tar.bz2
android-node-v8-4d798e1b1bbbbbf0a45fb478e153621fc37bb242.zip
bootstrap: provide usable error on missing internal module
Due to how bootstrap/loaders.js itself is loaded and invoked, stacktraces from it are munged and no longer point back to the error source. That resulted in the following unhelpful error if an internal module was missing or misnamed: ``` internal/bootstrap/loaders.js:190 return mod.compile(); ^ TypeError: Cannot read property 'compile' of undefined ``` This changes that to at least print the id that was attempted to be loaded: ``` internal/bootstrap/loaders.js:189 if (!mod) throw new TypeError(`Missing internal module '${id}'`); ^ TypeError: Missing internal module 'internal/a' ``` PR-URL: https://github.com/nodejs/node/pull/29593 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/internal/bootstrap/loaders.js')
-rw-r--r--lib/internal/bootstrap/loaders.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js
index 2889df4812..cc1157a557 100644
--- a/lib/internal/bootstrap/loaders.js
+++ b/lib/internal/bootstrap/loaders.js
@@ -186,6 +186,9 @@ function nativeModuleRequire(id) {
}
const mod = NativeModule.map.get(id);
+ // Can't load the internal errors module from here, have to use a raw error.
+ // eslint-disable-next-line no-restricted-syntax
+ if (!mod) throw new TypeError(`Missing internal module '${id}'`);
return mod.compile();
}