ERR_INSPECTOR_COMMAND
Node.jsERRORCriticalInspectorHIGH confidence

Inspector command failed

Production Risk

Low — inspector usage is confined to development and profiling tools.

What this means

Thrown when a command sent via inspector.Session.post() fails. The error contains the error code and message returned by the Chrome DevTools Protocol. Common causes include invalid method names, wrong parameters, or calling commands in an invalid order.

Why it happens
  1. 1Sending an invalid Chrome DevTools Protocol method name
  2. 2Providing incorrect or missing parameters for a CDP command
  3. 3Calling a CDP domain command before enabling the domain
How to reproduce

Triggered when a CDP command sent via session.post() returns an error response.

trigger — this will error
trigger — this will error
const inspector = require('inspector');
const session = new inspector.Session();
session.connect();
session.post('Runtime.unknownMethod', {}, (err) => {
  if (err) console.error(err.code); // ERR_INSPECTOR_COMMAND
});

expected output

Error [ERR_INSPECTOR_COMMAND]: Inspector error code: -32601 - Method not found

Fix 1

Enable the CDP domain before calling its methods

WHEN When using CDP domains that require explicit enabling

Enable the CDP domain before calling its methods
session.post('Profiler.enable', {}, () => {
  session.post('Profiler.start', {}, () => {
    // profiling is now active
  });
});

Why this works

CDP domains must be enabled before their methods can be called; enabling first prevents command errors.

Fix 2

Handle command errors in the callback

WHEN For all session.post() calls

Handle command errors in the callback
session.post('Runtime.evaluate', { expression: '1+1' }, (err, result) => {
  if (err) {
    console.error('CDP command failed:', err.message);
    return;
  }
  console.log(result.result.value); // 2
});

Why this works

Checking the err argument in the callback allows graceful handling of CDP failures.

Code examples
Triggerjs
const inspector = require('inspector');
const session = new inspector.Session();
session.connect();
session.post('Runtime.unknownMethod', {}, (err) => {
  if (err) console.error(err.code); // ERR_INSPECTOR_COMMAND
});  // this triggers ERR_INSPECTOR_COMMAND
Handle in try/catchjs
try {
  // operation that may throw ERR_INSPECTOR_COMMAND
  riskyOperation()
} catch (err) {
  if (err.code === 'ERR_INSPECTOR_COMMAND') {
    console.error('ERR_INSPECTOR_COMMAND:', err.message)
  } else {
    throw err
  }
}
Defensive pattern to avoid itjs
// Validate inputs before calling the operation
function safe_err_inspector_command(...args) {
  // validate args here
  return performOperation(...args)
}
What not to do

Ignore the error argument in session.post() callbacks

CDP command failures are only reported via the error callback; ignoring them hides bugs.

Sources
Official documentation ↗

Node.js Error Codes Documentation

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Node.js errors