Skip to content

fix(channels): bound inbound debounce key-chain — steal from unsettled flushes (tulgey#238)#15

Merged
matin merged 1 commit into
mainfrom
fix-inbound-debounce-chain
Jun 5, 2026
Merged

fix(channels): bound inbound debounce key-chain — steal from unsettled flushes (tulgey#238)#15
matin merged 1 commit into
mainfrom
fix-inbound-debounce-chain

Conversation

@matin

@matin matin commented Jun 5, 2026

Copy link
Copy Markdown
Owner

The chat-deafness bug: one hung flush permanently parked all later messages for that chat (inbound logged, command queue never reached). Live-confirmed via inspector lane dump: lanes completely empty while messages arrived. Bounded chain wait (5 min, env-tunable) + steal + warn naming the key. Regression test: never-settling flush no longer deafens the chat; ordering preserved on the happy path.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved inbound message processing resilience to prevent hung operations from permanently blocking subsequent messages in the same chat.
  • Tests

    • Added test coverage for message processing chain recovery scenarios.

…ettled flushes

A flush whose downstream work never settles (hung pre-agent media call in
processMessage) parked every later inbound for that chat key on a dead promise
chain: messages logged as Inbound, never reached the command queue, and the
chat went permanently silent until restart re-primed the same poison. Fourth
member of the unbounded await-the-prior-holder family (session lock #6,
models.json #11, lane slot #12). Bounded at OPENCLAW_INBOUND_CHAIN_WAIT_MS
(default 5 min) with a warn naming the chat key.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@matin matin merged commit 73af58d into main Jun 5, 2026
@matin matin deleted the fix-inbound-debounce-chain branch June 5, 2026 22:48
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Lost in the diff? Review this PR in Change Stack to follow the change map from intent to exact ranges.

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 86edd4c5-f265-40d5-92b7-2203ed0400f7

📥 Commits

Reviewing files that changed from the base of the PR and between 5ca6acf and e708944.

📒 Files selected for processing (2)
  • src/auto-reply/inbound-debounce.chain-steal.test.ts
  • src/auto-reply/inbound-debounce.ts

📝 Walkthrough

Walkthrough

The PR introduces a chain-steal mechanism to the inbound debouncer. Per-key task execution now uses a bounded timeout on prior promises; if a prior flush hangs beyond the configurable threshold, the chain is stolen and the new task proceeds with a warning. Two test cases verify that hung first flushes don't block second messages and that ordering is preserved when tasks settle normally.

Changes

Inbound Debouncer Chain Steal Mechanism

Layer / File(s) Summary
Bounded Promise Chaining with Timeout
src/auto-reply/inbound-debounce.ts
KEY_CHAIN_WAIT_MS is derived from the OPENCLAW_INBOUND_CHAIN_WAIT_MS environment variable (default 300 seconds), and a boundedPrevious(key, previous) helper races the prior per-key promise against this timeout. If the timeout fires, a warning is logged and the new task proceeds; otherwise, the prior task is awaited.
Chain Steal Behavior Tests
src/auto-reply/inbound-debounce.chain-steal.test.ts
Two test cases: (1) simulates a permanently pending first flush, verifies the second message still flushes using vi.stubEnv to set the timeout, and asserts the timeout error allows the second enqueue to complete; (2) verifies that message ordering ("a" then "b") is preserved when flushes settle normally.

🎯 3 (Moderate) | ⏱️ ~20 minutes

A debouncer's chain once got stuck,
But now we steal when luck runs out,
With timeouts brief and warnings clear,
No message waits in hanging fear! 🐇⏱️

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-inbound-debounce-chain

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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