it0/packages/services/agent-service/src
hailin 0d5441f720 fix(wecom): token mutex, leader lease, backoff, watchdog
Four additional robustness fixes:

1. **Token refresh mutex** — tokenRefreshPromise deduplicates concurrent
   refresh calls. All callers share one in-flight HTTP request instead
   of each firing their own, eliminating the race condition.

2. **Distributed leader lease** — service_state table used for a
   TTL-based leader election (LEADER_LEASE_TTL_S=90s). Only one
   agent-service instance polls at a time; others skip until the lease
   expires. Lease auto-released on graceful shutdown.

3. **Exponential backoff** — consecutive poll errors increment a counter;
   next delay = min(10s × 2^(n-1), 5min). Prevents log spam and
   reduces load during sustained WeCom API outages. Counter resets on
   any successful poll.

4. **Watchdog timer** — setInterval every 2min checks lastPollAt.
   If poll loop has been silent for >5min, clears the timer and
   reschedules immediately, recovering from any silent crash.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 05:54:42 -07:00
..
application feat: implement complete commercial monetization loop (Phases 1-4) 2026-03-03 21:09:17 -08:00
domain feat(agent-instance-chat): 实现用户与自己的 OpenClaw 智能体直接对话功能 2026-03-09 19:30:38 -07:00
infrastructure fix(wecom): token mutex, leader lease, backoff, watchdog 2026-03-10 05:54:42 -07:00
interfaces feat(instance-chat): full multimodal attachment support via OpenClaw bridge 2026-03-09 21:18:14 -07:00
agent.module.ts feat(wecom): add WeChat Customer Service channel — sync_msg polling + code binding + bridge callback 2026-03-09 10:54:36 -07:00
main.ts fix: increase body parser limit to 50mb for large PDF uploads 2026-02-28 05:35:43 -08:00