{"record":{"id":"ea96e5e2d430657c","repo":"jackwener/OpenCLI","slug":"waiting-for-v2ex-a2-session-cookie","errorCode":null,"errorMessage":"Waiting for V2EX A2 session cookie","messagePattern":"Waiting for V2EX A2 session cookie","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"info","filePath":"clis/v2ex/auth.js","lineNumber":40,"sourceCode":"      if (!username) return { kind: 'auth', detail: 'V2EX member link present but username empty' };\n      return { ok: true, username };\n    })()\n  `);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('v2ex.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected V2EX probe: ${JSON.stringify(probe)}`);\n  return { username: probe.username };\n}\n\nregisterSiteAuthCommands({\n  site: 'v2ex',\n  domain: 'v2ex.com',\n  loginUrl: 'https://www.v2ex.com/signin',\n  columns: ['username'],\n  quickCheck: hasV2exAuthCookie,\n  verify: verifyV2exIdentity,\n  poll: async (page) => {\n    if (!await hasV2exAuthCookie(page)) {\n      throw new AuthRequiredError('v2ex.com', 'Waiting for V2EX A2 session cookie');\n    }\n    return verifyV2exIdentity(page);\n  },\n});\n","sourceCodeStart":22,"sourceCodeEnd":45,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/v2ex/auth.js#L22-L45","documentation":"The v2ex auth poll callback throws AuthRequiredError('v2ex.com', 'Waiting for V2EX A2 session cookie') while the login window is open but the browser does not yet have a non-empty A2 cookie for v2ex.com. A2 is V2EX's httpOnly logged-in session cookie, so this error is the polling loop's way of saying 'login not finished yet' — it is transient and expected during interactive login, only becoming a real failure if the cookie never appears.","triggerScenarios":"The poll command runs hasV2exAuthCookie(page) (page.getCookies({url:'https://www.v2ex.com'}) filtered for name==='A2' with a non-empty value) during the login wait and the cookie is absent or empty.","commonSituations":"User is mid-way through the V2EX sign-in form (or has not submitted it); login succeeded on a different domain/subdomain so the cookie isn't scoped to www.v2ex.com; V2EX requires an extra verification step (2FA/verification email) before issuing A2; cookies were blocked or the browser profile was cleared.","solutions":["Complete the sign-in at https://www.v2ex.com/signin in the automation browser until redirected to the logged-in homepage.","Check cookies for v2ex.com to confirm A2 exists; if login seems done but A2 is missing, log out and log in again.","Complete any additional V2EX verification step (2FA, email confirmation) that prevents session issuance.","Ensure third-party/automation browser settings aren't blocking cookies, then retry the poll."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const cookies = await page.getCookies({ url: 'https://www.v2ex.com' });\nconst hasA2 = cookies.some(c => c.name === 'A2' && c.value);\nconsole.log('A2 cookie present:', hasA2);","typeGuard":"function hasA2Cookie(cookies) {\n  return Array.isArray(cookies) && cookies.some(c => c.name === 'A2' && typeof c.value === 'string' && c.value.length > 0);\n}","tryCatchPattern":"try {\n  await pollLogin(page);\n} catch (e) {\n  if (e instanceof AuthRequiredError && /Waiting for V2EX A2/.test(e.message)) {\n    // still mid-login: keep the window open, prompt user, poll again\n  } else throw e;\n}","preventionTips":["Keep the login browser window open until redirected to the logged-in homepage.","Complete any V2EX 2FA/email verification before expecting the A2 cookie.","Confirm cookies are enabled and not wiped between the login and poll steps.","Poll with backoff rather than treating this transient error as fatal."],"tags":["auth","cookies","login-flow","polling"],"backgroundTag":"session-cookie-missing","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}