Skip to content

Fix remote request amplification and reconnect storms - #607

Open
insane66613 wants to merge 1 commit into
wonderwhy-er:mainfrom
insane66613:codex/remote-channel-request-amplification
Open

Fix remote request amplification and reconnect storms#607
insane66613 wants to merge 1 commit into
wonderwhy-er:mainfrom
insane66613:codex/remote-channel-request-amplification

Conversation

@insane66613

@insane66613 insane66613 commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • make heartbeat startup idempotent so repeated initialization cannot create duplicate timers
  • deduplicate replayed realtime tool calls by bounded call-ID history
  • add exponential reconnect backoff capped at five minutes

Verification

  • npm run build
  • node test/test-remote-channel-reconnect.js (7 passing cases)

Summary by CodeRabbit

  • Bug Fixes

    • Prevented duplicate realtime tool calls from being processed more than once.
    • Improved connection recovery by adding throttled retries with increasing backoff after failures.
    • Strengthened heartbeat management to avoid duplicate timers and ensure tracking remains associated with the correct device.
  • Tests

    • Added regression coverage for duplicate calls, heartbeat behavior, and reconnect backoff.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5c98288c-55eb-46a2-bbcb-cc0e1f007968

📥 Commits

Reviewing files that changed from the base of the PR and between 1eccc8b and 905c71f.

📒 Files selected for processing (2)
  • src/remote-device/remote-channel.ts
  • test/test-remote-channel-reconnect.js

📝 Walkthrough

Walkthrough

RemoteChannel now throttles failed recreations with exponential backoff, deduplicates realtime tool calls using a bounded cache, and tracks heartbeat ownership per device. Regression tests cover reconnect throttling, duplicate calls, and idempotent heartbeat startup.

Changes

RemoteChannel safeguards

Layer / File(s) Summary
Reconnect throttling and recovery
src/remote-device/remote-channel.ts, test/test-remote-channel-reconnect.js
Reconnect attempts are guarded by nextReconnectAt, failed recreations schedule capped exponential delays, and successful subscriptions reset the throttle.
Realtime call deduplication
src/remote-device/remote-channel.ts, test/test-remote-channel-reconnect.js
Realtime INSERT events are processed once per call ID, with older IDs evicted after the bounded cache limit is reached.
Device-aware heartbeat lifecycle
src/remote-device/remote-channel.ts, test/test-remote-channel-reconnect.js
Heartbeat startup skips duplicate requests for the active device, replaces heartbeats when the device changes, and clears tracked ownership when stopped.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: size:M

Suggested reviewers: edgarsskore

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main changes: deduplicating remote calls and adding reconnect backoff to prevent storms.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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