{"record":{"id":"0ef84b0f20f9ac87","repo":"jackwener/OpenCLI","slug":"weixin-search-failed-while-loading-sogou-results","errorCode":null,"errorMessage":"weixin search failed while loading Sogou results","messagePattern":"weixin search failed while loading Sogou results","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/weixin/search.js","lineNumber":119,"sourceCode":"    func: async (page, kwargs) => {\n        const query = String(kwargs.query ?? '').trim();\n        if (!query) {\n            throw new ArgumentError('A search query is required.', 'Pass a non-empty keyword to search Weixin articles via Sogou.');\n        }\n\n        const pageNo = normalizePage(kwargs.page);\n        const limit = normalizeLimit(kwargs.limit);\n        const searchUrl = buildSearchUrl(query, pageNo);\n\n        let payload;\n        try {\n            await page.goto(searchUrl);\n            await page.wait(2);\n            payload = await page.evaluate(buildExtractSearchResultsEvaluate());\n        }\n        catch (error) {\n            const detail = error instanceof Error ? error.message : String(error);\n            throw new CommandExecutionError('weixin search failed while loading Sogou results', detail);\n        }\n\n        if (!payload || typeof payload !== 'object' || !Array.isArray(payload.rows)) {\n            throw new CommandExecutionError('weixin search returned an unreadable browser payload', 'Sogou Weixin may have changed its result page structure.');\n        }\n        if (payload.blocked) {\n            throw new CommandExecutionError('Sogou Weixin blocked this search request', 'Open weixin.sogou.com in Chrome and complete any verification before retrying.');\n        }\n        if (payload.invalidCount > 0) {\n            throw new CommandExecutionError('Sogou Weixin returned article cards without required title or URL', 'The result page structure may have changed; refusing to return a partial result set.');\n        }\n\n        const rows = payload.rows;\n        if (rows.length === 0 && payload.empty) {\n            throw new EmptyResultError('weixin search', 'Try a different keyword or a different page number.');\n        }\n        if (rows.length === 0) {\n            throw new CommandExecutionError('weixin search did not expose article result cards', 'Sogou Weixin may have changed its selectors or returned a transient shell page.');","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weixin/search.js#L101-L137","documentation":"This CommandExecutionError wraps any failure that occurs while the headless browser navigates to the Sogou Weixin search URL or extracts results. The original error message (timeout, navigation failure, page.evaluate crash) is preserved as the detail argument. It signals the scraping step itself failed, not that results were empty or blocked.","triggerScenarios":"page.goto to the Sogou search URL times out or is interrupted; page.wait or page.evaluate throws (e.g. a selector/DOM API changed, browser crashed); network errors reaching weixin.sogou.com during result-page load.","commonSituations":"Slow or flaky network / proxy causing navigation timeouts; Sogou serving a challenge page that breaks the evaluate script; transient browser automation failures after long sessions.","solutions":["Re-run the command once — transient navigation timeouts are common","Check network/proxy connectivity to weixin.sogou.com (curl the search URL)","Increase the navigation/wait timeout in the CLI config if available","Read the wrapped `detail` message to identify the underlying browser failure"],"exampleFix":"// before\nawait page.goto(searchUrl);\n// after (caller retries on failure)\ntry { const rows = await cli.weixinSearch(query); }\ncatch (e) { if (isTransient(e)) return retry(() => cli.weixinSearch(query), 2); throw e; }","handlingStrategy":"retry","validationCode":"await fetch('https://weixin.sogou.com').then(r => { if (!r.ok) throw new Error('sogou unreachable'); });","typeGuard":null,"tryCatchPattern":"try { rows = await weixinSearch(q); }\ncatch (e) {\n  if (String(e.message).includes('failed while loading')) return retry(weixinSearch, { retries: 2, backoff: 'exponential' });\n  throw e;\n}","preventionTips":["Add retry with backoff around search calls","Ensure stable network/proxy to weixin.sogou.com","Avoid concurrent searches hammering the browser"],"tags":["browser-automation","network","scraping","timeout"],"backgroundTag":"page-navigation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}