{"record":{"id":"2e02ad310aee3887","repo":"jackwener/OpenCLI","slug":"xianyu-chat-did-not-observe-the-sent-message-se","errorCode":null,"errorMessage":"Xianyu chat did not observe the sent message: ${sent?.reason || 'unknown-reason'}","messagePattern":"Xianyu chat did not observe the sent message: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/xianyu/chat.js","lineNumber":51,"sourceCode":"            throw selectorError('闲鱼聊天输入框', '未找到可用的聊天输入框，请确认该会话页已正确加载');\n        }\n        if (!text) {\n            return [{\n                status: 'ready',\n                peer_name: state.peer_name || '',\n                item_title: state.item_title || '',\n                price: state.price || '',\n                location: state.location || '',\n                message: (state.visible_messages || []).slice(-1)[0] || '',\n                peer_user_id: userId,\n                item_id: itemId,\n                url,\n                item_url: state.item_url || '',\n            }];\n        }\n        const sent = requireEvaluateObject(await page.evaluate(buildSendMessageEvaluate(text)), 'chat send');\n        if (!sent?.ok) {\n            throw new CommandExecutionError(`Xianyu chat did not observe the sent message: ${sent?.reason || 'unknown-reason'}`);\n        }\n        await page.wait(1);\n        return [{\n            status: 'sent',\n            peer_name: state.peer_name || '',\n            item_title: state.item_title || '',\n            price: state.price || '',\n            location: state.location || '',\n            message: text,\n            peer_user_id: userId,\n            item_id: itemId,\n            url,\n            item_url: state.item_url || '',\n        }];\n    },\n});\n\nexport const __test__ = {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xianyu/chat.js#L33-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"Message blocked by Xianyu risk control / content filter; peer conversation closed; transient network hiccup during submit; layout drift broke the send confirmation detection.","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"],"exampleFix":"// before\nawait sendXianyuChat({ itemId, userId, text });\n// after\ntry {\n  await sendXianyuChat({ itemId, userId, text });\n} catch (e) {\n  if (/did not observe the sent message/.test(e.message)) {\n    await page.wait(2);\n    await sendXianyuChat({ itemId, userId, text }); // retry once\n  } else throw e;\n}","handlingStrategy":"retry","validationCode":"const state = requireEvaluateObject(await page.evaluate(buildExtractChatStateEvaluate()), 'chat');\nif (!state?.can_input) throw new Error('input box unavailable; aborting send');","typeGuard":"function isSendConfirmed(x) {\n  return x != null && typeof x === 'object' && x.ok === true;\n}","tryCatchPattern":"try {\n  await sendXianyuChat(kwargs);\n} catch (e) {\n  if (/did not observe the sent message/.test(e.message)) {\n    await sleep(2000);\n    await sendXianyuChat(kwargs); // single retry\n  } else throw e;\n}","preventionTips":["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"],"tags":["xianyu","chat","send-failure"],"backgroundTag":"send-confirmation-missing","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}