{"record":{"id":"7f9a51812c582fcd","repo":"jackwener/OpenCLI","slug":"waiting-for-jimeng-login","errorCode":null,"errorMessage":"Waiting for Jimeng login","messagePattern":"Waiting for Jimeng login","errorType":"exception","errorClass":"AuthRequiredError('jimeng.jianying.com')","httpStatus":null,"severity":"info","filePath":"clis/jimeng/auth.js","lineNumber":43,"sourceCode":"  await page.goto('https://jimeng.jianying.com/ai-tool/generate?type=image&workspace=0');\n  await page.wait(2);\n  const probe = await page.evaluate(WHOAMI_PROBE);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('jimeng.jianying.com', probe.detail);\n  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Jimeng passport`);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`Jimeng whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Jimeng probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, screen_name: probe.screen_name };\n}\n\nregisterSiteAuthCommands({\n  site: 'jimeng',\n  domain: 'jimeng.jianying.com',\n  loginUrl: 'https://jimeng.jianying.com/',\n  columns: ['user_id', 'screen_name'],\n  verify: verifyJimengIdentity,\n  poll: async (page) => {\n    const probe = await page.evaluate(WHOAMI_PROBE);\n    if (!probe?.ok) throw new AuthRequiredError('jimeng.jianying.com', 'Waiting for Jimeng login');\n    return { user_id: probe.user_id, screen_name: probe.screen_name };\n  },\n});\n","sourceCodeStart":25,"sourceCodeEnd":47,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/jimeng/auth.js#L25-L47","documentation":"During the Jimeng login wait, the poll callback evaluates WHOAMI_PROBE and, while the probe does not report ok (user not yet signed in), throws AuthRequiredError('Waiting for Jimeng login'). This is the expected control-flow signal that the interactive login flow should keep polling until the user completes sign-in.","triggerScenarios":"The registerSiteAuthCommands login/poll loop invokes poll(page) before the user has finished signing in at jimeng.jianying.com — probe.ok is falsy on every poll until login completes.","commonSituations":"Normal mid-login polling; user closed the browser without signing in (error loops indefinitely); slow manual login exceeding the flow's timeout; probing a tab that isn't on the Jimeng domain.","solutions":["Complete the sign-in in the attached Chrome window — this error is expected until then","Make sure the active tab is on jimeng.jianying.com so the probe runs in the right page","If you already logged in but it still fails, reload the page so fresh cookies are visible to the probe","Extend the login timeout if sign-in takes long; abort and rerun the login command if the browser was closed","Verify cookies persisted (not incognito/profile mismatch) if repeated logins never succeed"],"exampleFix":"// before\nawait loginFlow.run(); // throws while waiting\n// after\ntry {\n  await loginFlow.run();\n} catch (err) {\n  if (err instanceof AuthRequiredError && err.message === 'Waiting for Jimeng login') {\n    console.error('Timed out waiting for Jimeng login — sign in at jimeng.jianying.com and rerun.');\n  }\n  throw err;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isWaitingForLogin(err) {\n  return err instanceof AuthRequiredError && err.message === 'Waiting for Jimeng login';\n}","tryCatchPattern":"try {\n  const identity = await loginFlow.wait();\n} catch (err) {\n  if (!isWaitingForLogin(err)) throw err;\n  // expected while polling: keep waiting or abort on timeout\n  throw new Error('Jimeng login not completed in time — sign in at jimeng.jianying.com and retry');\n}","preventionTips":["Treat this error as normal mid-login polling, not a failure","Keep the browser tab focused on jimeng.jianying.com during login","Set a sane polling timeout and a clear abort message","Ensure cookies persist (avoid incognito or ephemeral profiles)"],"tags":["auth","login-flow","jimeng","polling"],"backgroundTag":"auth-required-login","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}