Skip to content

Commit 327fdbc

Browse files
authored
module: simplify --inspect-brk handling
nodejs/node#55679
1 parent fdd11bc commit 327fdbc

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

patches/node/chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loade
1111
index 364469160af5e348f8890417de16a63c0d1dca67..75d5f58fe02fa8cfa7716ffaf761d567ab403a2c 100644
1212
--- a/lib/internal/modules/cjs/loader.js
1313
+++ b/lib/internal/modules/cjs/loader.js
14-
@@ -1441,6 +1441,13 @@ Module.prototype._compile = function(content, filename, loadAsESM = false) {
15-
if (getOptionValue('--inspect-brk') && process._eval == null) {
16-
if (!resolvedArgv) {
17-
// We enter the repl if we're not given a filename argument.
18-
+ // process._firstFileName is used by Embedders to tell node what
19-
+ // the first "real" file is when they use themselves as the entry
20-
+ // point
21-
+ if (process._firstFileName) {
22-
+ resolvedArgv = process._firstFileName
23-
+ delete process._firstFileName
24-
+ } else
25-
if (process.argv[1]) {
26-
try {
27-
resolvedArgv = Module._resolveFilename(process.argv[1], null, false);
14+
@@ -1530,6 +1530,13 @@ Module.prototype._compile = function(content, filename, format) {
15+
this[kIsExecuting] = true;
16+
if (this[kIsMainSymbol] && getOptionValue('--inspect-brk')) {
17+
const { callAndPauseOnStart } = internalBinding('inspector');
18+
+ // process._firstFileName is used by Embedders to tell node what
19+
+ // the first "real" file is when they use themselves as the entry
20+
+ // point
21+
+ if (process._firstFileName) {
22+
+ resolvedArgv = process._firstFileName;
23+
+ delete process._firstFileName;
24+
+ }
25+
result = callAndPauseOnStart(compiledWrapper, thisValue, exports,
26+
require, module, filename, dirname,
27+
process, localGlobal, localBuffer);
2828
diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js
2929
index 0bbabb80c26a1208860f6d32447c0ae53316f501..ba18bfa3cd17c2b8e977f53651ce2744b17a829f 100644
3030
--- a/lib/internal/process/pre_execution.js

patches/node/pass_all_globals_through_require.patch

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ index c284b39b1ac13eaea8776b7b4f457c084dce5fb8..c794751ecd4448119ce33d661e694f83
2323
const {
2424
isProxy,
2525
} = require('internal/util/types');
26-
@@ -1464,10 +1471,12 @@ Module.prototype._compile = function(content, filename, loadAsESM = false) {
27-
this[kIsExecuting] = true;
28-
if (inspectorWrapper) {
29-
result = inspectorWrapper(compiledWrapper, thisValue, exports,
30-
- require, module, filename, dirname);
31-
+ require, module, filename, dirname,
32-
+ process, localGlobal, localBuffer);
26+
@@ -1524,10 +1524,12 @@ Module.prototype._compile = function(content, filename, format) {
27+
if (this[kIsMainSymbol] && getOptionValue('--inspect-brk')) {
28+
const { callAndPauseOnStart } = internalBinding('inspector');
29+
result = callAndPauseOnStart(compiledWrapper, thisValue, exports,
30+
- require, module, filename, dirname);
31+
+ require, module, filename, dirname,
32+
+ process, localGlobal, localBuffer);
3333
} else {
3434
result = ReflectApply(compiledWrapper, thisValue,
3535
- [exports, require, module, filename, dirname]);
36-
+ [exports, require, module, filename,
37-
+ dirname, process, localGlobal, localBuffer]);
36+
+ [exports, require, module, filename, dirname,
37+
+ process, localGlobal, localBuffer]);
3838
}
3939
this[kIsExecuting] = false;
4040
if (requireDepth === 0) { statCache = null; }

0 commit comments

Comments
 (0)