diegosouzapw/OmniRoute · error · Error

TPROXY capture mode is already running

Error message

TPROXY capture mode is already running

What it means

Singleton guard in startCaptureMode: the module-level `active` capture session is non-null, so a second decrypt-capable TPROXY capture cannot start — iptables rules and the dynamic CA are bound to the existing session. Means stop the current capture before starting a new one; not an error of the capture machinery itself.

Solutions

  1. Call stop on the active capture session first
  2. Query the capture status to reuse the running session
  3. Serialize start/stop calls from the UI or API layer
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/mitm/tproxy/captureManager.ts:74 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/21e049977a7c53d6. Report an issue: GitHub.

Appendix: source

Thrown at src/mitm/tproxy/captureManager.ts:74

}

interface ActiveCapture {
  handle: TproxyCaptureHandle;
  startedAt: string;
  intercepts: { count: number };
}

let active: ActiveCapture | null = null;

/**
 * Start the decrypt-capable TPROXY capture mode. Rejects if a session is already
 * running or the native addon is unavailable. The dynamic CA is created here and
 * installed in the trust store via the injected `installCa`.
 */
export async function startCaptureMode(
  options: StartCaptureModeOptions
): Promise<CaptureManagerStatus> {
  if (active) throw new Error("TPROXY capture mode is already running");

  const deps: CaptureManagerDeps = { ...realDeps, ...options.deps };
  if (!deps.isAvailable()) {
    throw new Error("TPROXY capture mode requires the native addon (Linux + CAP_NET_ADMIN).");
  }

  const certStore = deps.createCertStore();
  const intercepts = { count: 0 };
  const handle = await deps.startTproxyCapture(options.cfg, {
    decrypt: { certStore, installCa: options.installCa, uninstallCa: options.uninstallCa },
    onIntercept: () => {
      intercepts.count += 1;
    },
  });
  active = { handle, startedAt: deps.now(), intercepts };
  return getCaptureStatus();
}

View on GitHub (pinned to a179ffed5b)