{"record":{"id":"64fb12e5068d682c","repo":"jackwener/OpenCLI","slug":"waiting-for-facebook-c-user-cookie","errorCode":null,"errorMessage":"Waiting for Facebook c_user cookie","messagePattern":"Waiting for Facebook c_user cookie","errorType":"error_code","errorClass":"AuthRequiredError","httpStatus":null,"severity":"info","filePath":"clis/facebook/auth.js","lineNumber":39,"sourceCode":"    throw new AuthRequiredError('www.facebook.com', `Facebook /me redirected to ${finalUrl} — logged out or in checkpoint`);\n  }\n  return {\n    user_id: String(cUser),\n    vanity: String(vanity),\n    profile_url: `https://www.facebook.com/${vanity}/`,\n  };\n}\n\nregisterSiteAuthCommands({\n  site: 'facebook',\n  domain: 'facebook.com',\n  loginUrl: 'https://www.facebook.com/login.php',\n  columns: ['user_id', 'vanity', 'profile_url'],\n  quickCheck: hasFacebookCUserCookie,\n  verify: verifyFacebookIdentity,\n  poll: async (page) => {\n    if (!await hasFacebookCUserCookie(page)) {\n      throw new AuthRequiredError('www.facebook.com', 'Waiting for Facebook c_user cookie');\n    }\n    return verifyFacebookIdentity(page);\n  },\n});\n","sourceCodeStart":21,"sourceCodeEnd":44,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/facebook/auth.js#L21-L44","documentation":"This is the polling hook of the Facebook login-wait flow: while the user completes login in the browser, poll repeatedly checks for the c_user cookie. Until it appears, poll throws AuthRequiredError with the informational message 'Waiting for Facebook c_user cookie' — this is the expected, transient state during login, not a hard failure. Once the cookie shows up, poll delegates to verifyFacebookIdentity for full verification.","triggerScenarios":"Calling the poll callback (page) while the user is on the Facebook login page and has not yet completed login: hasFacebookCUserCookie(page) returns false because no non-empty c_user cookie is set yet.","commonSituations":"User still typing credentials mid-login; user abandoned the login window; Facebook showed an intermediate page (2FA) that has not yet set c_user; automation started polling before the login page even loaded.","solutions":["Keep waiting — the CLI's login-wait loop treats this as the normal in-progress state and retries until the cookie appears.","Complete the Facebook login in the automated browser window (including 2FA) so c_user gets set.","If polling keeps failing after login succeeded, check cookies via page.getCookies({url:'https://www.facebook.com'}) for a non-empty c_user.","Restart the login flow with a clean page if the login window was closed or timed out."],"exampleFix":"// before\nawait loginAndPoll(page); // surfaces AuthRequiredError while waiting\n\n// after\ntry {\n  await loginAndPoll(page);\n} catch (err) {\n  if (!(err instanceof AuthRequiredError && err.message === 'Waiting for Facebook c_user cookie')) {\n    throw err; // only unexpected auth errors should propagate\n  }\n}","handlingStrategy":"retry","validationCode":"const cookies = await page.getCookies({ url: 'https://www.facebook.com' });\nif (!cookies.some(c => c.name === 'c_user' && c.value)) {\n  // still logged out — show 'waiting for login' UI and keep polling\n}","typeGuard":"function isWaitingForLogin(err) {\n  return err instanceof AuthRequiredError && err.message === 'Waiting for Facebook c_user cookie';\n}","tryCatchPattern":"while (!done) {\n  try {\n    result = await poll(page);\n    done = true;\n  } catch (err) {\n    if (!(err instanceof AuthRequiredError)) throw err;\n    await sleep(2000); // expected while the user completes login\n  }\n}","preventionTips":["Treat this specific AuthRequiredError message as 'keep polling', not a failure.","Set a sensible overall login timeout so abandoned logins do not poll forever.","Check that c_user appears with a non-empty value — empty strings do not count.","Surface a 'complete login in the browser' prompt so users know why it is waiting."],"tags":["authentication","cookies","facebook","polling"],"backgroundTag":"auth-pending-login","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}