jackwener/OpenCLI · info · AuthRequiredError

Waiting for V2EX A2 session cookie

Error message

Waiting for V2EX A2 session cookie

What it means

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.

Source

Thrown at clis/v2ex/auth.js:40

      if (!username) return { kind: 'auth', detail: 'V2EX member link present but username empty' };
      return { ok: true, username };
    })()
  `);
  if (probe?.kind === 'auth') throw new AuthRequiredError('v2ex.com', probe.detail);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected V2EX probe: ${JSON.stringify(probe)}`);
  return { username: probe.username };
}

registerSiteAuthCommands({
  site: 'v2ex',
  domain: 'v2ex.com',
  loginUrl: 'https://www.v2ex.com/signin',
  columns: ['username'],
  quickCheck: hasV2exAuthCookie,
  verify: verifyV2exIdentity,
  poll: async (page) => {
    if (!await hasV2exAuthCookie(page)) {
      throw new AuthRequiredError('v2ex.com', 'Waiting for V2EX A2 session cookie');
    }
    return verifyV2exIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Complete the sign-in at https://www.v2ex.com/signin in the automation browser until redirected to the logged-in homepage.
  2. Check cookies for v2ex.com to confirm A2 exists; if login seems done but A2 is missing, log out and log in again.
  3. Complete any additional V2EX verification step (2FA, email confirmation) that prevents session issuance.
  4. Ensure third-party/automation browser settings aren't blocking cookies, then retry the poll.
Defensive patterns

Strategy: retry

Validate before calling

const cookies = await page.getCookies({ url: 'https://www.v2ex.com' });
const hasA2 = cookies.some(c => c.name === 'A2' && c.value);
console.log('A2 cookie present:', hasA2);

Type guard

function hasA2Cookie(cookies) {
  return Array.isArray(cookies) && cookies.some(c => c.name === 'A2' && typeof c.value === 'string' && c.value.length > 0);
}

Try / catch

try {
  await pollLogin(page);
} catch (e) {
  if (e instanceof AuthRequiredError && /Waiting for V2EX A2/.test(e.message)) {
    // still mid-login: keep the window open, prompt user, poll again
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/ea96e5e2d430657c. Report an issue: GitHub.