Skip to content

fix(monitor): keep polling while handling inbound messages#92

Open
wowyuarm wants to merge 1 commit into
Tencent:mainfrom
wowyuarm:fix/nonblocking-inbound-monitor
Open

fix(monitor): keep polling while handling inbound messages#92
wowyuarm wants to merge 1 commit into
Tencent:mainfrom
wowyuarm:fix/nonblocking-inbound-monitor

Conversation

@wowyuarm
Copy link
Copy Markdown

Summary

  • Do not await processOneMessage(...) inside the long-poll message loop.
  • Process inbound Weixin messages in background tasks so the next getUpdates poll can continue while an agent reply is still running.
  • Add a bounded in-flight cap (MAX_IN_FLIGHT_MESSAGES = 32) and log per-message processing failures.
  • Add a monitor test that proves polling continues while an inbound message handler is still pending.

Why

OpenClaw already has message queue behavior such as messages.queue.mode = "steer", but it only works after the follow-up message reaches OpenClaw.

Before this change, the Weixin monitor awaited the full processOneMessage(...) path. That path can include agent generation and outbound reply delivery, so a follow-up Weixin message could stay behind the plugin's long-poll loop until the previous reply fully finished. In that case OpenClaw never sees the follow-up in time, so queue steering cannot take effect.

This change lets the monitor keep polling and hand later messages to OpenClaw while an earlier reply is still in progress.

Related symptoms discussed in existing issues include inbound aggregation/order/loss reports (#83, #65, #66), but I did not find an existing issue or PR for this exact blocking point.

Tests

  • npm run typecheck
  • npm run build
  • npx vitest run src/monitor/monitor.test.ts src/api/config-cache.test.ts

Note: npm test currently fails on src/auth/pairing.test.ts > registerUserInFrameworkStore > uses withFileLock for concurrency safety. I reproduced the same failure on a clean origin/main worktree, so it appears unrelated to this change.

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