{"record":{"id":"ad5022131d738536","repo":"musistudio/claude-code-router","slug":"browser-event-subscription-was-not-found-subscr","errorCode":null,"errorMessage":"Browser event subscription was not found: ${subscriptionId}","messagePattern":"Browser event subscription was not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/electron/src/main/browser-automation-mcp.ts","lineNumber":1361,"sourceCode":"      timedOut: matched.length === 0\n    };\n  }\n\n  private unsubscribeEvents(args: Record<string, unknown>): unknown {\n    const subscription = this.requireSubscription(args);\n    subscription.unsubscribe();\n    this.subscriptions.delete(subscription.subscriptionId);\n    return {\n      ok: true,\n      subscriptionId: subscription.subscriptionId\n    };\n  }\n\n  private requireSubscription(args: Record<string, unknown>): EventSubscription {\n    const subscriptionId = requiredString(args.subscriptionId, \"Browser event subscriptionId is required.\");\n    const subscription = this.subscriptions.get(subscriptionId);\n    if (!subscription) {\n      throw new Error(`Browser event subscription was not found: ${subscriptionId}`);\n    }\n    return subscription;\n  }\n\n  private requestHandoff(args: Record<string, unknown>): unknown {\n    const session = this.resolveOptionalSession(args);\n    const sessionId = session?.ref.sessionId || readString(args.browserSessionId);\n    const tabId = readString(args.tabId) || session?.ref.tabId;\n    const handoff = builtInBrowserService.requestAutomationHandoff({\n      kind: readHandoffKind(args.kind),\n      message: readString(args.message),\n      reason: requiredString(args.reason, \"browser_handoff_request requires reason.\"),\n      sessionId,\n      tabId\n    });\n    return {\n      ...humanHelpResultFields(handoff),\n      state: browserWindowState()","sourceCodeStart":1343,"sourceCodeEnd":1379,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/electron/src/main/browser-automation-mcp.ts#L1343-L1379","documentation":"Thrown by requireSubscription when browser event tool calls reference a subscriptionId that is not present in the MCP server's subscription map. Subscriptions are registered by an event-subscribe tool and keyed by the id it returns; unknown or evicted ids fail here.","triggerScenarios":"Calling an event-unsubscribe or event-poll tool with a subscriptionId that was never registered, was already unsubscribed, or was lost when its tab/session was cleaned up.","commonSituations":"Unsubscribing twice with the same id; using a subscription id after the app restarted; the subscription's tab closed and cascade-removed it.","solutions":["Use the exact subscriptionId returned by the subscribe call.","Track unsubscribe state so you don't call it twice with the same id.","After a restart or tab close, re-subscribe to obtain fresh ids."],"exampleFix":"// before\nawait call(\"browser_events_unsubscribe\", { subscriptionId });\nawait call(\"browser_events_unsubscribe\", { subscriptionId }); // second call throws\n\n// after\nawait call(\"browser_events_unsubscribe\", { subscriptionId });\nactiveSubscriptions.delete(subscriptionId); // guard against double unsubscribe","handlingStrategy":"try-catch","validationCode":"if (!activeSubscriptions.has(subscriptionId)) throw new Error(\"subscription already removed or unknown\");\nawait call(\"browser_events_unsubscribe\", { subscriptionId });\nactiveSubscriptions.delete(subscriptionId);","typeGuard":null,"tryCatchPattern":"try { await call(\"browser_events_unsubscribe\", { subscriptionId }); } catch (e) { if (e instanceof Error && e.message.includes(\"subscription was not found\")) { /* idempotent cleanup — ignore */ } else throw e; }","preventionTips":["Track live subscription ids in a Set","Make unsubscribe idempotent by swallowing not-found","Re-subscribe after restarts"],"tags":["mcp","browser-automation","subscription-not-found","events"],"backgroundTag":"subscription-id-not-found","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}