Skip to content

fix(weixin): guard res.text() with 5s timeout + persist contextToken to disk#6

Open
hooben2026 wants to merge 1 commit into
ImGoodBai:mainfrom
hooben2026:fix/res-text-timeout-context-token-persist
Open

fix(weixin): guard res.text() with 5s timeout + persist contextToken to disk#6
hooben2026 wants to merge 1 commit into
ImGoodBai:mainfrom
hooben2026:fix/res-text-timeout-context-token-persist

Conversation

@hooben2026

Copy link
Copy Markdown

Summary

  • Fix res.text() hang: Wrap res.text() with a secondary 5-second AbortController timeout using Promise.race to prevent hangs when the server accepts the connection but never sends a body
  • Fix monitor.ts first-poll timing: Move pollStartedAt to outer scope (before loop) and add firstPollLogged guard so first-poll-failure errors report correct elapsed time
  • Persist contextToken to disk: Save contextTokenStore to ~/.openclaw/openclaw-weixin/context-tokens.json on every setContextToken() call and reload on startup, preventing token loss across restarts

Changes

  • src/api/api.ts: apiFetch timeout guard
  • src/api/monitor.ts: pollStartedAt + firstPollLogged
  • src/api/inbound.ts: contextTokenStore disk persistence

…to disk

- apiPostFetch: wrap res.text() with a secondary 5s AbortController
  timeout to prevent hanging when the server accepts the connection
  but never sends a response body (Promise.race pattern)
- monitor: move pollStartedAt to outer scope so the first-poll-failure
  catch path can report elapsed time; add firstPollLogged guard
  so the verbose first-failure log only fires once
- inbound: persist contextTokenStore to ~/.openclaw/clawbnb-weixin/
  context-tokens.json on every setContextToken() call so tokens
  survive gateway restarts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant