jackwener/OpenCLI · error · AuthRequiredError
请先在共享 Chrome 完成 1688 登录/验证,再重试(${action})
Error message
请先在共享 Chrome 完成 1688 登录/验证,再重试(${action}) What it means
assertAuthenticatedState inspects the read page state and throws AuthRequiredError when the state looks like a 1688 captcha or login wall. The library requires a logged-in, captcha-free shared Chrome session for 1688 operations, so it fails fast with instructions (in Chinese) rather than scraping garbage from a verification page.
Source
Thrown at clis/1688/shared.js:413
}
catch (error) {
const message = error instanceof Error ? error.message : String(error);
if (message.includes('Inspected target navigated or closed')
|| message.includes('Cannot find context with specified id')
|| message.includes('Target closed')) {
throw new CommandExecutionError(`1688 ${action} navigation lost the current browser target`, `${buildCaptchaHint(action)} If CDP is attached to a stale or blocked tab, open a fresh 1688 tab and point OPENCLI_CDP_TARGET at that tab.`);
}
throw error;
}
}
export async function ensure1688Session(page) {
const state = await gotoAndReadState(page, HOME_URL, 1500, 'homepage');
assertAuthenticatedState(state, 'homepage');
}
export function assertAuthenticatedState(state, action) {
if (!isCaptchaState(state) && !isLoginState(state))
return;
throw new AuthRequiredError('1688.com', `请先在共享 Chrome 完成 1688 登录/验证,再重试(${action})`);
}
export function assertNotCaptcha(state, action) {
assertAuthenticatedState(state, action);
}
export function toNumber(value) {
if (typeof value === 'number' && Number.isFinite(value)) {
return value;
}
if (typeof value === 'string') {
const normalized = value.replace(/,/g, '').trim();
if (!normalized)
return null;
const parsed = Number.parseFloat(normalized);
return Number.isFinite(parsed) ? parsed : null;
}
return null;
}
export function limitCandidates(values, limit) {View on GitHub (pinned to 49907e53dc)
Solutions
- Open the shared Chrome instance, log in to 1688.com and complete any slider/captcha verification manually, then rerun the command (action name in the message shows which step failed).
- Confirm the CDP target tab actually shows 1688 logged-in state (not a login wall) before retrying.
- Slow down request rate / change to a cleaner network or a warm session if captchas recur.
Example fix
// before opencli 1688 store https://shop.1688.com/ // -> AuthRequiredError, session is a login wall // after logging in + captcha in shared Chrome opencli 1688 store https://shop.1688.com/
Defensive patterns
Strategy: try-catch
Validate before calling
// precheck: is the session logged in and captcha-free before running commands?
const state = await readCurrent1688State();
const ok = !(await import('./clis/1688/shared.js')).isCaptchaState(state)
&& !(await import('./clis/1688/shared.js')).isLoginState(state);
if (!ok) throw new Error('Complete 1688 login/captcha in shared Chrome first'); Type guard
function isAuthed1688State(state) {
return Boolean(state && !state.isLoginWall && !state.isCaptcha);
} Try / catch
try {
await run1688Command();
} catch (e) {
if (e instanceof AuthRequiredError) {
console.error('Action needed: open shared Chrome, log into 1688.com and finish the slider/captcha, then retry.');
// optionally open the login page for the user
} else throw e;
} Prevention
- Check login state at session start before running batch jobs.
- Keep the shared Chrome 1688 session warm; re-login periodically.
- Avoid datacenter IPs that trigger captchas; prefer a residential/warm session.
- Throttle request rates to reduce anti-bot challenges.
When it happens
Trigger: Calling any 1688 command whose flow calls ensure1688Session/assertAuthenticatedState while the shared Chrome tab shows 1688's login page or a slider/captcha challenge — e.g. session cookies expired, IP flagged, or the user logged out.
Common situations: 1688 cookie/session expired overnight; shared Chrome never logged into 1688; datacenter IP triggering anti-bot captcha; account forced logout; automation hitting the site too aggressively.
Related errors
- Ctrip is asking for a captcha; complete it in your browser s
- Ctrip is asking for a captcha; complete it in your browser s
- Ctrip flight API returned HTTP ${status}; complete any verif
- hotels.ctrip.com
- vacations.ctrip.com
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/cdb0796645f22e64.
Report an issue: GitHub.