{"record":{"id":"ceaac477d18e1252","repo":"jackwener/OpenCLI","slug":"waiting-for-wechat-channels-sessionid-cookie","errorCode":null,"errorMessage":"Waiting for WeChat Channels sessionid cookie","messagePattern":"Waiting for WeChat Channels sessionid cookie","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"warning","filePath":"clis/wechat-channels/auth.js","lineNumber":58,"sourceCode":"    }\n  })()`);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('channels.weixin.qq.com', probe.detail);\n  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from auth_data`);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`WeChat Channels whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected WeChat Channels probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'wechat-channels',\n  domain: 'channels.weixin.qq.com',\n  loginUrl: 'https://channels.weixin.qq.com/login.html?from=assistant',\n  columns: ['user_id', 'name'],\n  quickCheck: hasWechatChannelsSessionCookie,\n  verify: verifyWechatChannelsIdentity,\n  poll: async (page) => {\n    if (!await hasWechatChannelsSessionCookie(page)) {\n      throw new AuthRequiredError('channels.weixin.qq.com', 'Waiting for WeChat Channels sessionid cookie');\n    }\n    return verifyWechatChannelsIdentity(page);\n  },\n});\n","sourceCodeStart":40,"sourceCodeEnd":63,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/wechat-channels/auth.js#L40-L63","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Scan the QR code promptly with the correct WeChat account; if it expired, reload login.html for a fresh code.","Ensure the login happens in the same browser profile/session the tool is polling.","After the cookie appears, verification runs automatically — no action needed on this error during polling.","If polling never succeeds despite login, confirm cookies are visible to page.getCookies({ url: 'https://channels.weixin.qq.com' }) (correct profile, not partitioned).","Restart the login flow if the QR expired multiple times."],"exampleFix":"// before\n// QR left on screen, user idle → repeated 'Waiting for WeChat Channels sessionid cookie'\n// after\n// 1. reload https://channels.weixin.qq.com/login.html?from=assistant\n// 2. scan the fresh QR within its validity window\n// 3. poll succeeds once sessionid is set","handlingStrategy":"try-catch","validationCode":"// Poll cookie presence yourself before/while waiting:\nconst cookies = await page.getCookies({ url: 'https://channels.weixin.qq.com' });\nconst ready = cookies.some(c => c.name === 'sessionid' && c.value);","typeGuard":"function hasSession(cookies) { return Array.isArray(cookies) && cookies.some(c => c.name === 'sessionid' && !!c.value); }","tryCatchPattern":"try {\n  await waitForLogin(page);\n} catch (e) {\n  if (/Waiting for WeChat Channels sessionid cookie/.test(e.message)) {\n    // still waiting: surface QR / prompt user, then keep polling\n    showQrPrompt();\n  } else throw e;\n}","preventionTips":["Prompt users to scan promptly; reload login.html if the QR expires","Ensure login occurs in the same browser profile the tool polls","Verify partitioned cookie settings don't hide sessionid from getCookies","Close the wait loop once the cookie appears instead of hammering polls"],"tags":["auth","login","polling","wechat","qr-code"],"backgroundTag":"auth-required-session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}