jackwener/OpenCLI · warning · AuthRequiredError

Waiting for Xiaoe XIAOEID/b_user_token cookie

Error message

Waiting for Xiaoe XIAOEID/b_user_token cookie

What it means

The poll handler, run repeatedly while waiting for the user to finish logging in, calls hasXiaoeAdminCookie and throws AuthRequiredError('Waiting for Xiaoe XIAOEID/b_user_token cookie') until the cookie appears. It is the expected signal during interactive login polling, not a fatal fault.

Source

Thrown at clis/xiaoe/auth.js:51

    throw new AuthRequiredError('xiaoe-tech.com', 'Xiaoe admin page showed login UI — anonymous session');
  }
  const userId = xiaoeId || unionId;
  if (!userId) {
    throw new CommandExecutionError('Xiaoe admin page rendered but no user_id cookie extractable — stale session');
  }
  return { user_id: String(userId), nickname: String(probe.domNick || '') };
}

registerSiteAuthCommands({
  site: 'xiaoe',
  domain: 'xiaoe-tech.com',
  loginUrl: 'https://admin.xiaoe-tech.com/',
  columns: ['user_id', 'nickname'],
  quickCheck: hasXiaoeAdminCookie,
  verify: verifyXiaoeIdentity,
  poll: async (page) => {
    if (!await hasXiaoeAdminCookie(page)) {
      throw new AuthRequiredError('xiaoe-tech.com', 'Waiting for Xiaoe XIAOEID/b_user_token cookie');
    }
    return verifyXiaoeIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Complete the login in the opened browser window (including WeChat scan if required) and keep polling.
  2. Ensure you log in on https://admin.xiaoe-tech.com/, not the h5 storefront.
  3. Extend the poll timeout if login (QR scan) takes longer than the allotted window.
  4. Verify the polling browser context is the same profile where the user is logging in.

Example fix

// before
await waitForAuth(page, { timeoutMs: 30000 }); // too short for QR login
// after
await waitForAuth(page, { timeoutMs: 120000, poll }); // allow time for WeChat QR scan
Defensive patterns

Strategy: retry

Validate before calling

while (Date.now() < deadline) {
  const cookies = await page.getCookies({ url: 'https://admin.xiaoe-tech.com' });
  if (cookies.some(c => (c.name === 'XIAOEID' || c.name === 'b_user_token') && c.value)) break;
  await sleep(1000);
}

Type guard

const hasCookie = cs => Array.isArray(cs) && cs.some(c => (c.name === 'XIAOEID' || c.name === 'b_user_token') && !!c.value);

Try / catch

try {
  await poll(page);
} catch (e) {
  if (e instanceof AuthRequiredError && /Waiting for Xiaoe/.test(e.message)) {
    await sleep(1000); // expected during login — keep polling
  } else throw e;
}

Prevention

When it happens

Trigger: Auth polling loop invokes poll(page) after the user opened the login URL, but page.getCookies({url:'https://admin.xiaoe-tech.com'}) still shows no non-empty XIAOEID or b_user_token.

Common situations: User has not completed the Xiaoe login/WeChat scan yet; user logged into the wrong account or a different domain (h5.xet.citv.cn instead of admin.xiaoe-tech.com); polling window too short before timeout.

Related errors


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