GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — module: simplify --inspect-brk handling · nodejs/node@f507c05

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/modules/cjs
    • loader.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/modules/cjs/loader.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js
+4-38Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,15 +1317,6 @@ Module.prototype.require = function(id) {
13171317
};
13181318

13191319
let requireModuleWarningMode;
1320-
/**
1321-
* Resolved path to `process.argv[1]` will be lazily placed here
1322-
* (needed for setting breakpoint when called with `--inspect-brk`).
1323-
* @type {string | undefined}
1324-
*/
1325-
let resolvedArgv;
1326-
let hasPausedEntry = false;
1327-
/** @type {import('vm').Script} */
1328-
13291320
/**
13301321
* Resolve and evaluate it synchronously as ESM if it's ESM.
13311322
* @param {Module} mod CJS module instance
@@ -1536,32 +1527,6 @@ Module.prototype._compile = function(content, filename, format) {
15361527
return;
15371528
}
15381529

1539-
// TODO(joyeecheung): the detection below is unnecessarily complex. Using the
1540-
// kIsMainSymbol, or a kBreakOnStartSymbol that gets passed from
1541-
// higher level instead of doing hacky detection here.
1542-
let inspectorWrapper = null;
1543-
if (getOptionValue('--inspect-brk') && process._eval == null) {
1544-
if (!resolvedArgv) {
1545-
// We enter the repl if we're not given a filename argument.
1546-
if (process.argv[1]) {
1547-
try {
1548-
resolvedArgv = Module._resolveFilename(process.argv[1], null, false);
1549-
} catch {
1550-
// We only expect this codepath to be reached in the case of a
1551-
// preloaded module (it will fail earlier with the main entry)
1552-
assert(ArrayIsArray(getOptionValue('--require')));
1553-
}
1554-
} else {
1555-
resolvedArgv = 'repl';
1556-
}
1557-
}
1558-
1559-
// Set breakpoint on module start
1560-
if (resolvedArgv && !hasPausedEntry && filename === resolvedArgv) {
1561-
hasPausedEntry = true;
1562-
inspectorWrapper = internalBinding('inspector').callAndPauseOnStart;
1563-
}
1564-
}
15651530
const dirname = path.dirname(filename);
15661531
const require = makeRequireFunction(this, redirects);
15671532
let result;
@@ -1571,9 +1536,10 @@ Module.prototype._compile = function(content, filename, format) {
15711536
if (requireDepth === 0) { statCache = new SafeMap(); }
15721537
setHasStartedUserCJSExecution();
15731538
this[kIsExecuting] = true;
1574-
if (inspectorWrapper) {
1575-
result = inspectorWrapper(compiledWrapper, thisValue, exports,
1576-
require, module, filename, dirname);
1539+
if (this[kIsMainSymbol] && getOptionValue('--inspect-brk')) {
1540+
const { callAndPauseOnStart } = internalBinding('inspector');
1541+
result = callAndPauseOnStart(compiledWrapper, thisValue, exports,
1542+
require, module, filename, dirname);
15771543
} else {
15781544
result = ReflectApply(compiledWrapper, thisValue,
15791545
[exports, require, module, filename, dirname]);

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.