jackwener/OpenCLI · error · CommandExecutionError
Xianyu chat did not observe the sent message: ${sent?.reason
Error message
Xianyu chat did not observe the sent message: ${sent?.reason || 'unknown-reason'} What it means
After running the send-message script, the returned object has ok=false, so the page did not confirm the message was observed as sent. The library throws CommandExecutionError with the page-reported reason (or 'unknown-reason') because delivery could not be verified.
Source
Thrown at clis/xianyu/chat.js:51
throw selectorError('闲鱼聊天输入框', '未找到可用的聊天输入框,请确认该会话页已正确加载');
}
if (!text) {
return [{
status: 'ready',
peer_name: state.peer_name || '',
item_title: state.item_title || '',
price: state.price || '',
location: state.location || '',
message: (state.visible_messages || []).slice(-1)[0] || '',
peer_user_id: userId,
item_id: itemId,
url,
item_url: state.item_url || '',
}];
}
const sent = requireEvaluateObject(await page.evaluate(buildSendMessageEvaluate(text)), 'chat send');
if (!sent?.ok) {
throw new CommandExecutionError(`Xianyu chat did not observe the sent message: ${sent?.reason || 'unknown-reason'}`);
}
await page.wait(1);
return [{
status: 'sent',
peer_name: state.peer_name || '',
item_title: state.item_title || '',
price: state.price || '',
location: state.location || '',
message: text,
peer_user_id: userId,
item_id: itemId,
url,
item_url: state.item_url || '',
}];
},
});
export const __test__ = {View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect sent.reason in the error context and address the specific cause (rate limit, blocked content, closed session)
- Retry the send after a short delay
- Re-verify the chat state (can_input) before sending
- Log in again if the session degraded, then retry
Example fix
// before
await sendXianyuChat({ itemId, userId, text });
// after
try {
await sendXianyuChat({ itemId, userId, text });
} catch (e) {
if (/did not observe the sent message/.test(e.message)) {
await page.wait(2);
await sendXianyuChat({ itemId, userId, text }); // retry once
} else throw e;
} Defensive patterns
Strategy: retry
Validate before calling
const state = requireEvaluateObject(await page.evaluate(buildExtractChatStateEvaluate()), 'chat');
if (!state?.can_input) throw new Error('input box unavailable; aborting send'); Type guard
function isSendConfirmed(x) {
return x != null && typeof x === 'object' && x.ok === true;
} Try / catch
try {
await sendXianyuChat(kwargs);
} catch (e) {
if (/did not observe the sent message/.test(e.message)) {
await sleep(2000);
await sendXianyuChat(kwargs); // single retry
} else throw e;
} Prevention
- Verify can_input in chat state before sending
- Avoid spamming messages that trigger risk control
- Log sent.reason for diagnosis
- Re-check session validity on repeated send failures
When it happens
Trigger: Calling the xianyu chat send command when buildSendMessageEvaluate succeeds in executing but sent.ok is falsy — e.g. input box disabled at send time, send button blocked, rate limit, or the DOM confirmation never appeared.
Common situations: Message blocked by Xianyu risk control / content filter; peer conversation closed; transient network hiccup during submit; layout drift broke the send confirmation detection.
Related errors
- Xianyu chat requires a logged-in browser session
- Failed to send message
- Failed to send Qianwen image prompt
- Failed to send Qianwen prompt
- Xianyu unb/tracknick cookie missing — anonymous
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/2e02ad310aee3887.
Report an issue: GitHub.