{"record":{"id":"535a15b19380bee9","repo":"jackwener/OpenCLI","slug":"failed-to-send-message-535a15","errorCode":null,"errorMessage":"Failed to send message","messagePattern":"Failed to send message","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/claude/send.js","lineNumber":40,"sourceCode":"        const prompt = requireNonEmptyPrompt(kwargs.prompt, 'claude send');\n\n        if (parseBoolFlag(kwargs.new)) {\n            await page.goto(CLAUDE_URL);\n            try {\n                await page.wait({ selector: COMPOSER_SELECTOR, timeout: 8 });\n            } catch {\n                // Composer didn't mount; ensureClaudeComposer below surfaces a typed error.\n            }\n        } else {\n            // ensureOnClaude now waits for the composer selector; the previous\n            // post-nav 2 s settle is covered by that event-based wait.\n            await ensureOnClaude(page);\n        }\n        await withRetry(() => ensureClaudeComposer(page, 'Claude send requires a visible composer on the current page.'));\n\n        const sendResult = await withRetry(() => sendMessage(page, prompt));\n        if (!sendResult?.ok) {\n            throw new CommandExecutionError(sendResult?.reason || 'Failed to send message');\n        }\n        return [{\n            Status: 'Success',\n            SubmittedBy: sendResult.method || 'send-button',\n            InjectedText: prompt,\n        }];\n    },\n});\n","sourceCodeStart":22,"sourceCodeEnd":49,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/claude/send.js#L22-L49","documentation":"This CommandExecutionError is thrown by the `claude send` command when sendMessage reports failure — the error message is sendResult.reason if provided, otherwise the generic 'Failed to send message'. It means the prompt could not be injected/submitted into the composer and sent, despite the composer being present.","triggerScenarios":"withRetry(() => sendMessage(page, prompt)) returns { ok: false } — the send button was not clickable, text injection failed, the composer was disabled (e.g. Claude at capacity or message queue full), the page navigated mid-send, or a send-button/textarea DOM change broke the send routine.","commonSituations":"Claude conversation is full or the model is overloaded so the send button is disabled; message length exceeds limits; Claude DOM update moving the send button; page reloaded between composer check and send; network hiccup during submission; rate limiting by Claude.","solutions":["Read sendResult.reason in the message (when present) for the specific cause and address it directly","Re-run the command — transient composer/submit races are often resolved on retry, and withRetry already retried the immediate window","Shorten the prompt if it may exceed Claude's message limits, and verify the conversation isn't full/at capacity","Refresh the conversation page in the automated browser (or rerun the command to reopen) so a stale DOM is replaced","Update the library if Claude changed its composer/send-button markup"],"exampleFix":"// before\nopencli claude send \"<very long prompt>\"   // send button disabled -> Failed to send message\n// after\nopencli claude send \"shorter prompt\"        # retry with valid-length prompt after page settles","handlingStrategy":"retry","validationCode":"// preflight: composer must exist and the prompt must be non-empty/reasonable\nif (!prompt || prompt.length > 100000) throw new Error('Prompt missing or too long for claude.ai');\nconst state = await getPageState(page);\nif (!state.isLoggedIn) throw new Error('Run `opencli claude auth` first');","typeGuard":"function isSendSuccess(sendResult) {\n  return !!sendResult && sendResult.ok === true && typeof sendResult.method === 'string';\n}","tryCatchPattern":"try {\n  await opencli.claude.send(prompt);\n} catch (e) {\n  if (e.message === 'Failed to send message' || e.message.startsWith('send failed')) {\n    await sleep(2000);\n    return opencli.claude.send(prompt);      // one retry after page settles\n  }\n  throw e;\n}","preventionTips":["Keep prompts within Claude's message size limits and verify the conversation isn't full","Retry once after a short delay — send races are common on freshly loaded pages","Refresh/reopen the conversation page if the DOM may be stale","Update the library when Claude changes composer/send-button markup"],"tags":["claude","send","browser","automation"],"backgroundTag":"message-send-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}