{"record":{"id":"c0feaf547f37ec08","repo":"jackwener/OpenCLI","slug":"zhihu-answer-download-request-failed-error-inst","errorCode":null,"errorMessage":"Zhihu answer download request failed: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Zhihu answer download request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/zhihu/download-helpers.js","lineNumber":197,"sourceCode":"        const errorCode = payload.error?.code ?? '';\n        const errorMessage = payload.error?.message || payload.error_msg || payload.message || '';\n        const needLogin = payload.error?.need_login === true || payload.need_login === true;\n        if (!response.ok || errorCode || errorMessage || needLogin) {\n          return { status: response.status, errorCode, errorMessage, needLogin };\n        }\n        if (typeof payload.content !== 'string') return { malformed: true };\n        const normalized = ${normalize}(payload.content, document);\n        return { value: {\n          answerUrl: typeof payload.url === 'string' ? payload.url : '',\n          questionUrl: typeof payload.question?.url === 'string' ? payload.question.url : '',\n          title: typeof payload.question?.title === 'string' ? payload.question.title : '',\n          author: typeof payload.author?.name === 'string' ? payload.author.name : '',\n          createdTime: payload.created_time,\n          ...normalized\n        } };\n      })()\n    `).catch((error) => {\n        throw new CommandExecutionError(\n            `Zhihu answer download request failed: ${error instanceof Error ? error.message : String(error)}`,\n            'Try again later or rerun with -v for more detail.',\n        );\n    });\n\n    const data = unwrapEvaluateResult(raw);\n    if (!data || typeof data !== 'object' || Array.isArray(data)) {\n        throw new CommandExecutionError('Zhihu answer download returned a malformed Browser Bridge payload');\n    }\n    const status = data.status;\n    if (String(data.errorCode) === '40362') {\n        throw new CommandExecutionError(\n            `Zhihu risk control blocked answer ${target.answerId} (40362): ${data.errorMessage || 'abnormal request'}`,\n            'Open the answer in the connected Chrome profile and retry later.',\n        );\n    }\n    if (status === 401 || status === 403 || String(data.errorCode) === '40353' || data.needLogin) {\n        throw new AuthRequiredError('www.zhihu.com', 'Failed to download Zhihu answer');","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/zhihu/download-helpers.js#L179-L215","documentation":"extractAnswer runs an in-page evaluate that fetches the Zhihu v4 answer API (with credentials) and normalizes the returned content HTML. If that whole evaluate script rejects — the browser context threw, the bridge connection broke, or serialization failed — the .catch rethrows it as a CommandExecutionError with a 'try again later / rerun with -v' hint. Note that in-page fetch/JSON errors are deliberately caught inside the script and returned as status/errorCode/malformed fields instead, so this wrapper indicates an evaluate-level failure, not an HTTP error.","triggerScenarios":"Calling extractAnswer when the page.evaluate promise rejects: the tab navigated or closed while fetch ran, the Browser Bridge connection dropped mid-request, a script-level exception escaped the internal try/catch blocks, or the evaluate result could not be marshaled back.","commonSituations":"Chrome closed or crashed during a long fetch; Zhihu risk control reloaded the page mid-call; network flakiness combined with bridge instability; very large answer content causing serialization issues in older bridge versions.","solutions":["Retry the command after a short wait — transient bridge/page instability is the usual cause.","Rerun with -v (verbose) to see the underlying evaluate error as the remediation hint suggests.","Reconnect the Browser Bridge / relaunch Chrome if the tab was lost, then retry.","Check page stability first: ensure no pending navigation or captcha wall on the answer page before calling."],"exampleFix":"// before\nconst data = await extractAnswer(page, target);\n// after\ntry {\n  const data = await extractAnswer(page, target);\n} catch (err) {\n  if (/download request failed/.test(err.message)) {\n    await sleep(5000); // hint says: try again later\n    return extractAnswer(page, target);\n  }\n  throw err;\n}","handlingStrategy":"retry","validationCode":"// ensure the page is stable and still on the answer before evaluating\nconst url = await page.getCurrentUrl();\nif (!url || !url.includes('/answer/')) {\n  throw new Error('page not on an answer; re-navigate before extraction');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const data = await extractAnswer(page, target);\n} catch (err) {\n  if (String(err.message).startsWith('Zhihu answer download request failed')) {\n    // library hint: try again later; retry with backoff and verbose logging\n    await sleep(5000);\n    return extractAnswer(page, target);\n  }\n  throw err;\n}","preventionTips":["Retry with backoff — the built-in hint explicitly says 'try again later'","Run with -v during development to capture the underlying evaluate error","Avoid concurrent downloads on one bridge tab; serialize extraction calls","Reconnect the bridge if Chrome has been running for a long session"],"tags":["browser-automation","network","fetch","zhihu"],"backgroundTag":"browser-bridge-evaluate-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}