Registry / devops / inspector-proxy

inspector-proxy

JSON →
library1.2.3jsnpmunverified

inspector-proxy is a utility for Node.js that enables proxying the built-in `inspector` debugger sessions. It is designed to simplify debugging scenarios, particularly when working with multiple Node.js processes (e.g., clustered applications, applications managed by `nodemon` or `cfork`) where individual debug ports might be dynamically assigned or need to be consolidated through a single entry point. The current stable version is 1.2.3. The release cadence appears to be low, with infrequent updates primarily focused on dependency maintenance. A key differentiator is its programmatic API, which allows developers to integrate the proxy directly into process management tools, automatically detecting and forwarding debugger connections from child processes to a single, stable proxy URL. It ships with TypeScript types, enhancing its usability in TypeScript projects.

npm install inspector-proxy
INSTALL
IMPORT
SIG · INSPECTOR-PROXY
I
inspector-proxy
devopsjavascriptv1.2.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

InspectorProxy
const InspectorProxy = require('inspector-proxy');
import InspectorProxy from 'inspector-proxy';
The primary API is a class exported as a CommonJS default. While it ships types, direct ESM default import might be problematic in some environments, or treated as `module.exports` being the default.
InspectorProxy
import InspectorProxy from 'inspector-proxy';
import { InspectorProxy } from 'inspector-proxy';
When using ESM syntax with TypeScript or compatible bundlers, import the class as a default export, not a named export, as it's a CommonJS module's `module.exports`.
InspectorProxyOptions
import type { InspectorProxyOptions } from 'inspector-proxy';
import { InspectorProxyOptions } from 'inspector-proxy';
When importing types in TypeScript, use `import type` to ensure the import is erased at compile time and doesn't introduce runtime dependencies.

Demonstrates how to programmatically start an inspector proxy and connect it to a child process, useful for orchestrating multi-process debugging.

import InspectorProxy from 'inspector-proxy'; import cfork from 'cfork'; const proxy = new InspectorProxy({ port: 9229 }); cfork({ exec: './test.js', // Replace with your actual script to be debugged execArgv: [ '--inspect' ], count: 1, refork: true, }).on('fork', worker => { let port: string | undefined; worker.process.spawnargs .some(arg => { let matches; // Node.js 6: --inspect=9888 // Node.js 8+: --inspect-port=9888 or --inspect (assigns random port) if (arg.startsWith('--inspect') && (matches = arg.match(/\d+/))) { port = matches[0]; return true; } return false; }); if (!port) { console.error('Could not determine debug port for worker.'); return; } proxy.start({ debugPort: parseInt(port, 10) }) .then(() => { console.log(`\nProxy URL: ${proxy.url}\n`); // You can now connect your debugger to this proxy URL }) .catch(err => { console.error('Failed to start proxy:', err); }); }); // Example test.js content (create this file for the example to run) /* console.log('Test script started. Waiting for debugger...'); let counter = 0; setInterval(() => { counter++; console.log('Counter:', counter); if (counter === 5) { debugger; // This will pause execution if debugger is attached } }, 1000); */
Debug
Known issues
gotchaThe example code for connecting to child processes relies on manually parsing `worker.process.spawnargs` to extract the debug port. This approach can be fragile and prone to breaking if Node.js changes its command-line argument format for the inspector, or if different `inspect` flags (`--inspect`, `--inspect-brk`) are used.
fix
Implement robust argument parsing or consider libraries that abstract away inspector port discovery if more stable integration is needed. For most standard Node.js usages, the current approach is usually sufficient.
affects: >=1.0.0
gotchaThe `inspector-proxy` package appears to be in maintenance mode, with infrequent updates primarily focused on dependency management rather than active feature development. Users should be aware that new features or rapid bug fixes are unlikely.
fix
Evaluate the package's existing functionality against your requirements. For stable and mature use cases, this may not be an issue. For evolving needs, consider the long-term support implications.
affects: >=1.0.0
gotchaThe `engines.node` field specifies `'>=6.0.0'`, indicating compatibility with very old Node.js versions. While this allows broad compatibility, it implies that the package itself may not leverage newer Node.js features or APIs. Users on modern Node.js versions should generally face no issues, but those targeting specific very old versions should ensure their Node.js environment is correctly set up.
fix
No direct fix needed unless you are targeting extremely old Node.js versions. Always test your application with the specific Node.js version you intend to deploy.
affects: >=1.0.0
Errors
Common errors & fixes
Error: listen EADDRINUSE: address already in use :::9229
The port specified for the inspector proxy (e.g., 9229) is already in use by another process on your system.
fix
Specify a different, unused port for the `InspectorProxy` constructor (e.g., `new InspectorProxy({ port: 9230 })`) or ensure no other application is listening on the desired port.
inspector-proxy: command not found
The `inspector-proxy` CLI tool was not found in your system's PATH, typically because it wasn't installed globally or its installation directory isn't included in PATH.
fix
Ensure you have installed the package globally using `npm install -g inspector-proxy` or `yarn global add inspector-proxy`. If it's installed locally and you want to use the CLI, prepend `npx` (e.g., `npx inspector-proxy ./test.js`).
TypeError: InspectorProxy is not a constructor
This usually indicates an incorrect import statement, such as attempting to use `import { InspectorProxy } from 'inspector-proxy';` when the package exports a default CommonJS module.
fix
For JavaScript, use `const InspectorProxy = require('inspector-proxy');`. For TypeScript/ESM, use `import InspectorProxy from 'inspector-proxy';` to correctly import the default export.
Upgrade
Version history
1.2.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
inspector-proxy — npm install inspector-proxy · libregistry