{"record":{"id":"42b3491825a78e95","repo":"jackwener/OpenCLI","slug":"chatwise-response","errorCode":null,"errorMessage":"ChatWise response","messagePattern":"ChatWise response","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"clis/chatwise/ask.js","lineNumber":47,"sourceCode":"        if (!injected)\n            throw selectorError('ChatWise input element');\n        await page.wait(0.5);\n        await page.pressKey('Enter');\n        // Poll for response\n        const pollInterval = 2;\n        const maxPolls = Math.ceil(timeout / pollInterval);\n        let response = '';\n        for (let i = 0; i < maxPolls; i++) {\n            await page.wait(pollInterval);\n            const result = await page.evaluate(buildChatwiseResponseAfterJs(beforeLen, text));\n            if (result) {\n                const next = String(result).trim();\n                if (next === response) break;\n                response = next;\n            }\n        }\n        if (!response) {\n            throw new TimeoutError('ChatWise response', timeout, 'Confirm ChatWise is done generating, then retry with a larger --timeout if needed.');\n        }\n        return [\n            { Role: 'User', Text: text },\n            { Role: 'Assistant', Text: response },\n        ];\n    },\n});\n","sourceCodeStart":29,"sourceCodeEnd":55,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatwise/ask.js#L29-L55","documentation":"ChatWise's ask command polls the page for the assistant's reply until the response text stops changing; this TimeoutError is thrown when the extracted response is still empty after the --timeout window expires, meaning ChatWise never produced any text in time. It exists to fail fast instead of returning an empty transcript.","triggerScenarios":"Calling the ChatWise ask flow with a --timeout (in seconds) that expires before the assistant message selector yields any non-empty text; e.g. a slow/large generation, a page that hasn't finished loading the composer, or a stuck ChatWise tab.","commonSituations":"Long prompts with big answers exceeding the default timeout; slow machine/network where rendering lags; ChatWise UI changes so the selector never matches; user forgot to pass a larger --timeout.","solutions":["Retry with a larger --timeout value (e.g. --timeout 120) once ChatWise has finished generating.","Confirm ChatWise is actually generating a reply and the tab/page is responsive.","Verify the DOM selector for the assistant response still matches the current ChatWise UI version.","Pre-warm the ChatWise session/page before submitting the prompt to cut load time out of the timeout window."],"exampleFix":"// before\nclis chatwise ask \"explain X\" --timeout 10\n// after\nclis chatwise ask \"explain X\" --timeout 120","handlingStrategy":"retry","validationCode":"const timeout = Number.parseInt(process.env.CHATWISE_TIMEOUT ?? '60', 10);\nif (!(timeout > 0)) throw new Error('CHATWISE_TIMEOUT must be a positive integer');","typeGuard":"function isValidTimeout(v) { return Number.isInteger(v) && v > 0; }","tryCatchPattern":"try {\n  const transcript = await chatwiseAsk(text, { timeout });\n} catch (err) {\n  if (err instanceof TimeoutError) {\n    // retry once with a doubled timeout\n    transcript = await chatwiseAsk(text, { timeout: timeout * 2 });\n  } else throw err;\n}","preventionTips":["Set a generous --timeout proportional to expected response length","Confirm ChatWise is responsive before issuing long prompts","Keep the ChatWise page pre-loaded to avoid load time counting against the timeout"],"tags":["timeout","browser-automation","chatwise"],"backgroundTag":"operation-timed-out","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}