jackwener/OpenCLI · error · CommandExecutionError

40362

40362

Error message

Zhihu risk control blocked ${label} (40362): ${payload.__errorMessage || 'abnormal request'}

What it means

Zhihu's API responded with errorCode 40362, its risk-control / abnormal-request signal. The library raises a dedicated CommandExecutionError telling the user to open the answer in the connected Chrome profile and retry, because automated requests have been flagged. This is an anti-bot block, not a code bug.

Source

Thrown at clis/zhihu/answer-comments-helpers.js:69

        return !response.ok || result.__errorCode || result.__errorMessage || result.__needLogin ? result : body;
    }, url).catch((error) => {
        throw new CommandExecutionError(
            `Zhihu ${label} request failed: ${error instanceof Error ? error.message : String(error)}`,
            'Try again later or rerun with -v for more detail.',
        );
    });
    const payload = unwrapEvaluateResult(evaluated);
    if (payload?.__malformedJson) {
        throw new CommandExecutionError(`Zhihu ${label} returned malformed JSON: ${payload.__malformedJson}`);
    }
    if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
        throw new CommandExecutionError(`Zhihu ${label} returned a malformed payload`);
    }
    const status = payload.__httpStatus;
    const code = String(payload.__errorCode || '');
    if (status >= 400 || code || payload.__errorMessage || payload.__needLogin) {
        if (code === '40362') {
            throw new CommandExecutionError(
                `Zhihu risk control blocked ${label} (40362): ${payload.__errorMessage || 'abnormal request'}`,
                'Open the answer in the connected Chrome profile and retry later.',
            );
        }
        if (status === 401 || status === 403 || code === '40353' || payload.__needLogin) {
            throw new AuthRequiredError('www.zhihu.com', `Failed to fetch Zhihu ${label}`);
        }
        if (status === 404 && notFoundDetail) throw new EmptyResultError('zhihu answer-comments', notFoundDetail);
        if (status >= 400) throw new CommandExecutionError(`Zhihu ${label} request failed (HTTP ${status})`);
        throw new CommandExecutionError(`Zhihu ${label} returned an error payload: ${payload.__errorMessage || code}`);
    }
    if (!Array.isArray(payload.data) || !payload.paging || typeof payload.paging !== 'object') {
        throw new CommandExecutionError(`Zhihu ${label} returned a malformed payload`);
    }
    if (typeof payload.paging.is_end !== 'boolean') {
        throw new CommandExecutionError(`Zhihu ${label} returned malformed paging state`);
    }
    return payload;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the answer URL in the connected Chrome profile and interact manually until the block clears, then retry
  2. Add delays/backoff between page fetches to reduce request frequency
  3. Use a residential/logged-in profile and avoid datacenter IPs
  4. Wait (hours if needed) — 40362 blocks are usually temporary

Example fix

// before
for (const url of urls) await fetchCommentPage(url); // tight loop -> 40362
// after
for (const url of urls) {
  await fetchCommentPage(url);
  await new Promise(r => setTimeout(r, 3000 + Math.random() * 2000)); // jittered delay
}
Defensive patterns

Strategy: retry

Validate before calling

// pre-check recent request volume before calling
if (requestsInLastMinute >= 10) await sleep(60000);

Try / catch

try { await fetchCommentPage(url); } catch (e) { if (e.message.includes('40362')) { await openInProfileAndAwaitHumanCheck(url); await sleep(cooldownMs); return fetchCommentPage(url); } throw e; }

Prevention

When it happens

Trigger: payload.__errorCode === '40362' on the comment fetch — Zhihu flagged the request as automated or abnormal (too-frequent polling, missing browser fingerprint cues, datacenter IP).

Common situations: Scraping too aggressively in a loop; running from a cloud/datacenter IP; profile cookies degraded after long idle; Zhihu tightening risk control during high-traffic periods.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/a9158cb5111a0dfb. Report an issue: GitHub.