diff options
author | Maƫl Nison <nison.mael@gmail.com> | 2019-11-08 18:38:26 +0100 |
---|---|---|
committer | Guy Bedford <guybedford@gmail.com> | 2019-12-04 23:30:25 -0500 |
commit | 1549c8e077422b79573936960daaa4c695620310 (patch) | |
tree | 5ee2a9e13960d7ee47c9493b58d2c42954c6276e /lib | |
parent | 81ac3023b3ab082804deda96d65530321d8af448 (diff) | |
download | android-node-v8-1549c8e077422b79573936960daaa4c695620310.tar.gz android-node-v8-1549c8e077422b79573936960daaa4c695620310.tar.bz2 android-node-v8-1549c8e077422b79573936960daaa4c695620310.zip |
module: ignore resolution failures for inspect-brk
The resolution for the main entry point may fail when the resolution
requires a preloaded module to be executed first (for example when
adding new extensions to the resolution process). Silently skipping
such failures allow us to defer the resolution as long as needed
without having any adverse change (since the main entry point won't
resolve anyway if it really can't be resolved at all).
PR-URL: https://github.com/nodejs/node/pull/30336
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/modules/cjs/loader.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 84b2b4772b..687d39563d 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -1164,14 +1164,20 @@ Module.prototype._compile = function(content, filename) { if (!resolvedArgv) { // We enter the repl if we're not given a filename argument. if (process.argv[1]) { - resolvedArgv = Module._resolveFilename(process.argv[1], null, false); + try { + resolvedArgv = Module._resolveFilename(process.argv[1], null, false); + } catch { + // We only expect this codepath to be reached in the case of a + // preloaded module (it will fail earlier with the main entry) + assert(Array.isArray(getOptionValue('--require'))); + } } else { resolvedArgv = 'repl'; } } // Set breakpoint on module start - if (!hasPausedEntry && filename === resolvedArgv) { + if (resolvedArgv && !hasPausedEntry && filename === resolvedArgv) { hasPausedEntry = true; inspectorWrapper = internalBinding('inspector').callAndPauseOnStart; } |