{"record":{"id":"bd47b5c532033269","repo":"NousResearch/hermes-agent","slug":"oauth-authorization-window-was-closed-before-compl","errorCode":null,"errorMessage":"OAuth authorization window was closed before completion","messagePattern":"OAuth authorization window was closed before completion","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"web/src/lib/mcp-dashboard-oauth.ts","lineNumber":62,"sourceCode":"\n  let pollFailures = 0;\n  for (;;) {\n    let current: McpOAuthFlow;\n    try {\n      current = await status(started.flow_id);\n      pollFailures = 0;\n    } catch (error) {\n      pollFailures += 1;\n      if (pollFailures >= maxPollFailures) throw error;\n      await sleep(1000);\n      continue;\n    }\n    if (current.status === \"approved\") return current;\n    if (current.status === \"error\") {\n      throw new Error(current.error || \"OAuth authorization failed\");\n    }\n    if (authWindow.closed) {\n      throw new Error(\"OAuth authorization window was closed before completion\");\n    }\n    await sleep(1000);\n  }\n}\n","sourceCodeStart":44,"sourceCodeEnd":67,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/web/src/lib/mcp-dashboard-oauth.ts#L44-L67","documentation":"The OAuth polling loop noticed authWindow.closed while the flow was still neither approved nor errored — the user closed the authorization popup before finishing consent. Since consent can never complete without that window, the flow is aborted immediately rather than polling forever.","triggerScenarios":"User manually closes the OAuth popup mid-flow; a popup-crushing browser extension or tab manager closes it; the provider's page crashes the popup; or the OS/browser reclaims the window on navigation.","commonSituations":"Users closing the 'extra window' thinking it's an ad; popup managers; slow provider pages where users give up.","solutions":["Click the OAuth button again and complete consent in the newly opened popup without closing it.","Disable tab/popup managers for the dashboard origin if they auto-close popups.","If the provider page itself crashes, troubleshoot that MCP server's OAuth endpoint separately."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await completeMcpDashboardOAuth({ serverName, start, status, open })\n} catch (err) {\n  if (String(err).includes('closed before completion')) {\n    toast('The OAuth window was closed — click connect again to restart')\n    return\n  }\n  throw err\n}","preventionTips":["Tell users (inline near the button) that a popup will open and must stay open.","Detect the closed window quickly (the poll loop does) and offer one-click restart.","Keep popup managers/extensions disabled for the dashboard origin."],"tags":["oauth","mcp","popup","user-action"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}