NativeScript/NativeScript · error · Error

One NetworkDomainDebugger may be enabled at a time.

Error message

One NetworkDomainDebugger may be enabled at a time.

What it means

On iOS the NetworkDomainDebugger (webinspector network domain) also permits only one enabled instance at a time. enable() throws when debuggerDomains.getNetwork() already returns a registered debugger. This enforces a single receiver of webinspector network events.

Source

Thrown at packages/core/debugger/webinspector-network.ios.ts:145

	constructor() {
		this.events = new inspectorCommands.NetworkDomain.NetworkFrontend();

		// By default start enabled because we can miss the "enable" event when
		// running with `--debug-brk` -- the frontend will send it before we've been created
		this.enable();
	}

	get enabled(): boolean {
		return this._enabled;
	}

	/**
	 * Enables network tracking, network events will now be delivered to the client.
	 */
	enable(): void {
		if (debuggerDomains.getNetwork()) {
			throw new Error('One NetworkDomainDebugger may be enabled at a time.');
		} else {
			debuggerDomains.setNetwork(this);
		}
		this._enabled = true;
	}

	/**
	 * Disables network tracking, prevents network events from being sent to the client.
	 */
	disable(): void {
		if (debuggerDomains.getNetwork() === this) {
			debuggerDomains.setNetwork(null);
		}
		this._enabled = false;
	}

	/**
	 * Specifies whether to always send extra HTTP headers with the requests from this page.

View on GitHub (pinned to 6800aefa65)

Solutions

  1. Use a single shared NetworkDomainDebugger instance across the app
  2. Disable the existing debugger (disable()) before enabling a new one
  3. Skip re-enabling if debuggerDomains already reports an active network debugger
  4. Clear registry state on hot reload before reconstruction

Example fix

// before
const dbg = new NetworkDomainDebugger(client);
// after
const existing = NetworkDomainDebugger.getInstance?.();
const dbg = existing ?? new NetworkDomainDebugger(client);
Defensive patterns

Strategy: try-catch

Validate before calling

let instance: NetworkDomainDebugger | null = null;
function getDebugger(client: Client) {
  if (!instance) instance = new NetworkDomainDebugger(client);
  return instance;
}

Type guard

function isDebuggerActive(): boolean {
  return typeof debuggerDomains !== 'undefined' && debuggerDomains.getNetwork() != null;
}

Try / catch

try {
  dbg.enable();
} catch (e) {
  if (/One NetworkDomainDebugger/.test(e.message)) return debuggerDomains.getNetwork();
  throw e;
}

Prevention

When it happens

Trigger: Calling enable() on a second NetworkDomainDebugger while the first remains enabled; the constructor auto-enables, so instantiating two debuggers for the same client/session throws; re-initializing after a page reload without disabling the prior instance.

Common situations: Hot reload recreating devtools clients on iOS; multiple debug sessions (e.g. Safari inspector and app inspector both creating instances); app re-entry from background rebuilding the inspector without teardown.

Related errors


AI-assisted analysis of NativeScript/NativeScript@6800aefa65 (2026-08-30). Data as JSON: /api/errors/1870a898bd17ea91. Report an issue: GitHub.