{"record":{"id":"0e5ebf3866973294","repo":"jackwener/OpenCLI","slug":"toutiao-articles-render-failed-error-message","errorCode":null,"errorMessage":"toutiao articles render failed: ${error?.message || error}","messagePattern":"toutiao articles render failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/toutiao/articles.js","lineNumber":35,"sourceCode":"    args: [\n        { name: 'page', type: 'int', default: 1, help: '页码 (1-4)' },\n    ],\n    columns: ['title', 'date', 'status', '展现', '阅读', '点赞', '评论'],\n    func: async (page, kwargs) => {\n        const articlePage = parseArticlesPage(kwargs.page, 1);\n        let text;\n        try {\n            await page.goto(`https://mp.toutiao.com/profile_v4/manage/content/all?page=${articlePage}`);\n            await page.wait('networkidle');\n            await page.wait(3);\n            text = await page.evaluate(`\n(async () => {\n    await new Promise(r => setTimeout(r, 2000));\n    return document.body.innerText || '';\n})()\n`);\n        } catch (error) {\n            throw new CommandExecutionError(`toutiao articles render failed: ${error?.message || error}`);\n        }\n        if (looksToutiaoAuthWallText(text)) {\n            throw new AuthRequiredError('mp.toutiao.com', 'Toutiao creator articles require a logged-in mp.toutiao.com browser session');\n        }\n        const rows = parseToutiaoArticlesText(text);\n        if (rows.length === 0) {\n            throw new EmptyResultError(\n                'toutiao articles',\n                `未抓取到创作者后台文章 (page=${articlePage})。可能页面尚未完成渲染或无文章。`,\n            );\n        }\n        return rows;\n    },\n});\n\nexport { parseToutiaoArticlesText };\nexport const __test__ = {\n    parseToutiaoArticlesText,","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/toutiao/articles.js#L17-L53","documentation":"The toutiao articles command renders the creator-backend page in a browser and extracts body text via an injected async IIFE; any failure inside that evaluation is re-thrown as a CommandExecutionError 'toutiao articles render failed: <msg>'. It wraps navigation timeouts, script errors, or page crashes from the render step.","triggerScenarios":"The page.evaluate-style call running the IIFE (2s wait then document.body.innerText) threw — navigation timeout, page closed/crashed, or the evaluation itself errored.","commonSituations":"Slow network so mp.toutiao.com didn't load within the timeout; browser crashed or was closed mid-render; Toutiao serving a challenge that breaks script execution; headless incompatibility with the page.","solutions":["Read the embedded message for the root cause (timeout vs crash vs script error)","Increase the render/navigation timeout and the 2000ms settle delay","Retry the command once — transient load issues often resolve","Verify the headless browser can load mp.toutiao.com at all (test manually / non-headless)"],"exampleFix":"// before\nawait new Promise(r => setTimeout(r, 2000));\nreturn document.body.innerText || '';\n// after\nawait page.waitForSelector('.article-list, body', { timeout: 15000 });\nawait new Promise(r => setTimeout(r, 3000));\nreturn document.body.innerText || '';","handlingStrategy":"try-catch","validationCode":"await page.goto('https://mp.toutiao.com', { waitUntil: 'domcontentloaded', timeout: 30000 });\nif (!document_title_ok) await page.waitForSelector('body', { timeout: 15000 });","typeGuard":"function isRenderFailure(e) { return /toutiao articles render failed/i.test(e?.message || ''); }","tryCatchPattern":"try { await fetchToutiaoArticles(); } catch (e) {\n  if (isRenderFailure(e)) {\n    await sleep(5000); return fetchToutiaoArticles(); // bounded retry\n  }\n  throw e;\n}","preventionTips":["Raise navigation and settle timeouts for slow loads","Wait for a real content selector instead of fixed 2s","Keep the browser alive and healthy (avoid closing pages mid-render)","Test headless vs headless=false if the page misbehaves"],"tags":["browser-automation","toutiao","render","command-execution"],"backgroundTag":"command-execution-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}