fix(monitor): treat UND_ERR_HEADERS_TIMEOUT as soft failure in getUpdates long-poll (#75)#187
Open
WilShi wants to merge 1 commit into
Open
Conversation
…ates long-poll (Tencent#75) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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