fix(weixin): drop manual Content-Length header rejected by undici#56
Open
yikkuro wants to merge 1 commit into
Open
fix(weixin): drop manual Content-Length header rejected by undici#56yikkuro wants to merge 1 commit into
yikkuro wants to merge 1 commit into
Conversation
buildHeaders() set a manual Content-Length on every WeChat API request. The gateway's bundled undici rejects a manually-set Content-Length with InvalidArgumentError: invalid content-length header (UND_ERR_INVALID_ARG), surfaced as 'TypeError: fetch failed'. Since buildHeaders() is used by every call (getUpdates, sendMessage, sendTyping, getConfig, getUploadUrl), the whole channel failed and WeChat showed '暂无法连接 OpenClaw'. Let fetch/undici compute Content-Length from the body automatically. Fixes #55 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
What
Removes the manual
Content-Lengthheader from the WeChat (weixin) plugin'sbuildHeaders().Why
The WeChat channel was completely broken: inbound messages went unanswered and the WeChat client showed "暂无法连接 OpenClaw". The gateway logged an endless stream of
TypeError: fetch failedforgetUpdates,sendMessage, andsendTyping.Root cause:
buildHeaders()setContent-Lengthmanually on every request. The gateway's bundled undici forbids this and throwsInvalidArgumentError: invalid content-length header(UND_ERR_INVALID_ARG), whichfetchre-wraps as the opaqueTypeError: fetch failed. BecausebuildHeaders()backs every API call, the entire channel failed.The real cause was hidden —
fetch failednever exposeserr.causein the logs, and the same request succeeds from a standalone Node process (top-level built-in fetch is more lenient than the gateway's undici). It was confirmed by temporarily wrappingglobalThis.fetchin the gateway to captureerr.cause.Fix
Delete the manual
Content-Lengthheader (and the now-unusedbodyparam ofbuildHeaders).fetch/undici computesContent-Lengthfrom the string body automatically.Verification
Applied to the live gateway plugin and restarted:
getUpdates/sendMessage/sendTypingfailed every ~2s withfetch failed.fetch failed, and a real WeChat "Hello" round-trips and receives a reply (confirmed by the reporter).Fixes #55