{"record":{"id":"e1bc1a33c3b8f20c","repo":"jackwener/OpenCLI","slug":"waiting-for-github-session-cookies","errorCode":null,"errorMessage":"Waiting for GitHub session cookies","messagePattern":"Waiting for GitHub session cookies","errorType":"error_code","errorClass":"AuthRequiredError","httpStatus":null,"severity":"warning","filePath":"clis/github/auth.js","lineNumber":40,"sourceCode":"  }\n  return {\n    id: identity.id || '',\n    username: identity.username,\n    name: identity.name || '',\n    url: `https://github.com/${identity.username}`,\n  };\n}\n\nregisterSiteAuthCommands({\n  site: 'github',\n  domain: 'github.com',\n  loginUrl: 'https://github.com/login',\n  columns: ['id', 'username', 'name', 'url'],\n  quickCheck: hasGithubSessionCookies,\n  verify: verifyGithubIdentity,\n  poll: async (page) => {\n    if (!await hasGithubSessionCookies(page)) {\n      throw new AuthRequiredError('github.com', 'Waiting for GitHub session cookies');\n    }\n    return verifyGithubIdentity(page);\n  },\n});\n","sourceCodeStart":22,"sourceCodeEnd":45,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/github/auth.js#L22-L45","documentation":"The GitHub site auth poll function checks hasGithubSessionCookies(page) on each polling tick during the interactive login flow and throws AuthRequiredError while the session cookies are absent. It is a transient 'not yet logged in' signal: once GitHub session cookies appear, polling proceeds to verifyGithubIdentity.","triggerScenarios":"During the login/poll loop for site 'github', a poll tick runs hasGithubSessionCookies(page) and it resolves false — the browser has not yet obtained GitHub session cookies (user hasn't completed login, or cookies were dropped).","commonSituations":"User hasn't finished the GitHub login form when polling starts; GitHub login requires 2FA and takes longer than expected; browser profile discards cookies (private mode, cookie blockers, third-party cookie restrictions); script closed the browser before cookies persisted.","solutions":["Complete the GitHub login in the browser window before/while polling continues","Check that the browser context allows cookies (not incognito with blockers, no extension stripping cookies)","Increase poll timeout to accommodate 2FA / SSO delays","Use a persistent user-data-dir profile so cookies survive restarts"],"exampleFix":"// before\nawait loginAndPoll(site, { timeout: 10_000 }); // too short for 2FA\n// after\nawait loginAndPoll(site, { timeout: 120_000 }); // allow time for manual login + 2FA","handlingStrategy":"retry","validationCode":"const cookies = await page.cookies('https://github.com');\nconst hasSession = cookies.some(c => c.name === 'user_session' || c.name === '__Host-user_session_same-site');\nif (!hasSession) await waitForGithubLogin(page, { timeoutMs: 120_000 });","typeGuard":"function hasGithubSession(cookies) {\n  return Array.isArray(cookies) && cookies.some(c => c.name === 'user_session');\n}","tryCatchPattern":"withRetries(async () => {\n  try { return await pollGithubAuth(page); }\n  catch (e) {\n    if (e instanceof AuthRequiredError && /Waiting for GitHub session cookies/.test(e.message)) return null; // keep polling\n    throw e;\n  }\n}, { until: r => r !== null, timeoutMs: 120_000 });","preventionTips":["Allow generous poll timeouts for manual login + 2FA","Keep cookies enabled; avoid incognito/blocking extensions","Use a persistent user-data-dir so cookies persist","Prompt the user to complete login before polling starts","Detect /login redirects early to avoid pointless poll cycles"],"tags":["auth","cookies","github","polling"],"backgroundTag":"auth-required-session-missing","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}