jackwener/OpenCLI · warning · AuthRequiredError

Waiting for WeChat Channels sessionid cookie

Error message

Waiting for WeChat Channels sessionid cookie

What it means

During the interactive login flow, the poll callback repeatedly checks for the sessionid cookie while the user scans the QR code. Each poll that finds no cookie yet throws this AuthRequiredError — it signals 'still waiting for you to complete login', not a hard failure, until the cookie appears and verification runs.

Source

Thrown at clis/wechat-channels/auth.js:58

    }
  })()`);
  if (probe?.kind === 'auth') throw new AuthRequiredError('channels.weixin.qq.com', probe.detail);
  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from auth_data`);
  if (probe?.kind === 'exception') throw new CommandExecutionError(`WeChat Channels whoami failed: ${probe.detail}`);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected WeChat Channels probe: ${JSON.stringify(probe)}`);
  return { user_id: probe.user_id, name: probe.name };
}

registerSiteAuthCommands({
  site: 'wechat-channels',
  domain: 'channels.weixin.qq.com',
  loginUrl: 'https://channels.weixin.qq.com/login.html?from=assistant',
  columns: ['user_id', 'name'],
  quickCheck: hasWechatChannelsSessionCookie,
  verify: verifyWechatChannelsIdentity,
  poll: async (page) => {
    if (!await hasWechatChannelsSessionCookie(page)) {
      throw new AuthRequiredError('channels.weixin.qq.com', 'Waiting for WeChat Channels sessionid cookie');
    }
    return verifyWechatChannelsIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Scan the QR code promptly with the correct WeChat account; if it expired, reload login.html for a fresh code.
  2. Ensure the login happens in the same browser profile/session the tool is polling.
  3. After the cookie appears, verification runs automatically — no action needed on this error during polling.
  4. If polling never succeeds despite login, confirm cookies are visible to page.getCookies({ url: 'https://channels.weixin.qq.com' }) (correct profile, not partitioned).
  5. Restart the login flow if the QR expired multiple times.

Example fix

// before
// QR left on screen, user idle → repeated 'Waiting for WeChat Channels sessionid cookie'
// after
// 1. reload https://channels.weixin.qq.com/login.html?from=assistant
// 2. scan the fresh QR within its validity window
// 3. poll succeeds once sessionid is set
Defensive patterns

Strategy: try-catch

Validate before calling

// Poll cookie presence yourself before/while waiting:
const cookies = await page.getCookies({ url: 'https://channels.weixin.qq.com' });
const ready = cookies.some(c => c.name === 'sessionid' && c.value);

Type guard

function hasSession(cookies) { return Array.isArray(cookies) && cookies.some(c => c.name === 'sessionid' && !!c.value); }

Try / catch

try {
  await waitForLogin(page);
} catch (e) {
  if (/Waiting for WeChat Channels sessionid cookie/.test(e.message)) {
    // still waiting: surface QR / prompt user, then keep polling
    showQrPrompt();
  } else throw e;
}

Prevention

When it happens

Trigger: poll() invoked while the user has not yet scanned the QR code at login.html; QR expired before scanning; user scanned with an account but the session cookie was set on a different domain/profile than the tool watches.

Common situations: Slow QR scanning past the code's expiry; scanning with the wrong WeChat account; browser profile mismatch (login happened in a different profile than the automation watches); user abandoned login.

Related errors


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