From c258e74b95977a8328495b270748c588b2b13294 Mon Sep 17 00:00:00 2001 From: Hanzo Dev Date: Wed, 8 Jul 2026 13:12:23 -0700 Subject: [PATCH] browser: legacy CDP opt-in + gentle native-zap poll MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Firefox no longer dials the dead ws://:9223/cdp bridge by default (it error-looped); it's opt-in via globalThis.HANZO_LEGACY_CDP, matching Chrome's native-ZAP-only default. And the ZAP native-host reconnect goes 3s -> 30s: with no MCP client there's no router, so hammering (and re-launching the host) every 3s was pure noise — a live consumer is still picked up within one interval. Pairs with zapd host connect-only. --- packages/browser/src/background-firefox.ts | 6 +++++- packages/browser/src/shared/native-zap.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/browser/src/background-firefox.ts b/packages/browser/src/background-firefox.ts index b0d84a2..ad14292 100644 --- a/packages/browser/src/background-firefox.ts +++ b/packages/browser/src/background-firefox.ts @@ -110,7 +110,11 @@ class HanzoFirefoxExtension { constructor() { console.log('[Hanzo] Firefox extension initializing...'); - this.connect(); + // Legacy ws://:9223 CDP bridge is OPT-IN (globalThis.HANZO_LEGACY_CDP). The + // default (and only) transport is the ZAP native host — see + // discoverZapServers() at EOF — matching Chrome. Without a bridge server the + // WS just error-looped, so it no longer runs unless explicitly enabled. + if ((globalThis as { HANZO_LEGACY_CDP?: boolean }).HANZO_LEGACY_CDP) this.connect(); } private connect(): void { diff --git a/packages/browser/src/shared/native-zap.ts b/packages/browser/src/shared/native-zap.ts index 06f21a3..d783d35 100644 --- a/packages/browser/src/shared/native-zap.ts +++ b/packages/browser/src/shared/native-zap.ts @@ -63,7 +63,11 @@ export interface NativeZapState { export type Dispatch = (method: string, params: any) => Promise | any; -const RECONNECT_MS = 3000; +// Gentle safe poll: with no MCP client running there is no router to reach, so +// the host connects-then-exits; probe every 30s instead of hammering (and +// re-launching the native host) every 3s. A live consumer is picked up within +// one interval. +const RECONNECT_MS = 30_000; /** Connect to zapd via the native host, register as a browser provider, and * dispatch inbound ROUTE commands to the browser. Self-heals on disconnect. */