fix(monitor): treat UND_ERR_HEADERS_TIMEOUT as soft failure in getUpdates long-poll (#75) - #187
Conversation
…ates long-poll (Tencent#75) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Thanks for investigating https://github.com/NewFuture/openclaw-weixin The current codebase already centralizes fetch error classification, so the preferred port would classify this timeout through the existing Contribution guide: For transparency, |
Fixes #75
Summary
getUpdateslong-poll intermittently enters 30s backoff afterUND_ERR_HEADERS_TIMEOUT, making the Weixin channel appear unavailable. This patch treatsUND_ERR_HEADERS_TIMEOUTas a soft failure in the monitor catch block.Root Cause
Node.js undici throws
HeadersTimeoutError(UND_ERR_HEADERS_TIMEOUT) when the server holds a long-poll connection open waiting for messages and none arrive within the timeout window. This is a normal long-poll boundary event, not a network fault.In
src/monitor/monitor.ts, the catch block treats all errors uniformly — any exception incrementsconsecutiveFailures. After 3 consecutive failures the monitor backs off for 30 seconds, during which no messages are received. If network conditions are unstable, this backoff cycle repeats, making the Weixin channel effectively unavailable.This was previously reported in openclaw/openclaw#67564 and redirected to this repository as issue #75.
Fix
src/monitor/monitor.ts: Added a check in the catch block (after theabortSignal.abortedguard) that detectsUND_ERR_HEADERS_TIMEOUTviaerr.cause.code. When matched, the error is logged at debug level and the loop retries afterRETRY_DELAY_MS(2s) without incrementing the failure counter. All other errors continue through the existing hard-failure path unchanged.UND_ERR_HEADERS_TIMEOUTUND_ERR_CONNECT_TIMEOUTUND_ERR_SOCKETENOTFOUND/ECONNREFUSED/EPROTOTest Plan