node-loop-detective 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -74,6 +74,9 @@ loop-detective -p 12345 -d 30 -t 100
74
74
  # Detect slow I/O with a 1-second threshold
75
75
  loop-detective -p 12345 --io-threshold 1000
76
76
 
77
+ # Connect to a remote inspector (Docker, K8s, remote server)
78
+ loop-detective --host 192.168.1.100 --port 9229
79
+
77
80
  # Continuous monitoring mode
78
81
  loop-detective -p 12345 --watch
79
82
 
@@ -86,6 +89,7 @@ loop-detective -p 12345 --json
86
89
  | Flag | Description | Default |
87
90
  |------|-------------|---------|
88
91
  | `-p, --pid <pid>` | Target Node.js process ID | — |
92
+ | `-H, --host <host>` | Inspector host (remote connections) | 127.0.0.1 |
89
93
  | `-P, --port <port>` | Inspector port (skip SIGUSR1) | — |
90
94
  | `-d, --duration <sec>` | Profiling duration in seconds | 10 |
91
95
  | `-t, --threshold <ms>` | Event loop lag threshold | 50 |
@@ -124,6 +128,7 @@ const { Detective } = require('node-loop-detective');
124
128
 
125
129
  const detective = new Detective({
126
130
  pid: 12345,
131
+ inspectorHost: '127.0.0.1', // or remote host
127
132
  duration: 10000,
128
133
  threshold: 50,
129
134
  interval: 100,
package/bin/cli.js CHANGED
@@ -10,6 +10,7 @@ function parseCliArgs(argv) {
10
10
  const args = argv.slice(2);
11
11
  const values = {
12
12
  pid: null,
13
+ host: null,
13
14
  port: null,
14
15
  duration: '10',
15
16
  threshold: '50',
@@ -24,6 +25,7 @@ function parseCliArgs(argv) {
24
25
 
25
26
  const flagMap = {
26
27
  '-p': 'pid', '--pid': 'pid',
28
+ '-H': 'host', '--host': 'host',
27
29
  '-P': 'port', '--port': 'port',
28
30
  '-d': 'duration', '--duration': 'duration',
29
31
  '-t': 'threshold', '--threshold': 'threshold',
@@ -85,9 +87,11 @@ function printUsage() {
85
87
  loop-detective <pid>
86
88
  loop-detective --pid <pid>
87
89
  loop-detective --port <inspector-port>
90
+ loop-detective --host <remote-host> --port <inspector-port>
88
91
 
89
92
  OPTIONS
90
93
  -p, --pid <pid> Target Node.js process ID
94
+ -H, --host <host> Inspector host (default: 127.0.0.1)
91
95
  -P, --port <port> Connect to an already-open inspector port
92
96
  -d, --duration <sec> Profiling duration in seconds (default: 10)
93
97
  -t, --threshold <ms> Event loop lag threshold in ms (default: 50)
@@ -102,6 +106,7 @@ function printUsage() {
102
106
  loop-detective 12345
103
107
  loop-detective --pid 12345 --duration 30 --threshold 100
104
108
  loop-detective --port 9229 --watch
109
+ loop-detective --host 192.168.1.100 --port 9229
105
110
  loop-detective -p 12345 -d 5 -j
106
111
 
107
112
  HOW IT WORKS
@@ -116,6 +121,7 @@ function printUsage() {
116
121
  async function main() {
117
122
  const config = {
118
123
  pid: pid ? parseInt(pid, 10) : null,
124
+ inspectorHost: values.host || '127.0.0.1',
119
125
  inspectorPort,
120
126
  duration: parseInt(values.duration, 10) * 1000,
121
127
  threshold: parseInt(values.threshold, 10),
@@ -128,6 +134,11 @@ async function main() {
128
134
  const reporter = new Reporter(config);
129
135
  const detective = new Detective(config);
130
136
 
137
+ // Security warning for remote connections
138
+ if (config.inspectorHost !== '127.0.0.1' && config.inspectorHost !== 'localhost') {
139
+ reporter.onInfo(`⚠ Warning: Connecting to remote host ${config.inspectorHost}. The CDP protocol has no authentication — ensure the network is trusted.`);
140
+ }
141
+
131
142
  detective.on('connected', () => reporter.onConnected());
132
143
  detective.on('lag', (data) => reporter.onLag(data));
133
144
  detective.on('slowIO', (data) => reporter.onSlowIO(data));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-loop-detective",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Detect event loop blocking & lag in running Node.js apps without code changes or restarts",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/detective.js CHANGED
@@ -406,7 +406,7 @@ class Detective extends EventEmitter {
406
406
  this._activateInspector();
407
407
  const port = await this._findInspectorPort();
408
408
 
409
- this.inspector = new Inspector({ port });
409
+ this.inspector = new Inspector({ host: this.config.inspectorHost, port });
410
410
  await this.inspector.connect();
411
411
  this.emit('connected');
412
412