Skip to content

fix(api-gateway): prevent rmb peer from wedging on failed (re)creation#89

Merged
ashraffouda merged 1 commit into
mainfrom
fix-peer-creation
Jul 22, 2026
Merged

fix(api-gateway): prevent rmb peer from wedging on failed (re)creation#89
ashraffouda merged 1 commit into
mainfrom
fix-peer-creation

Conversation

@ashraffouda

Copy link
Copy Markdown
Collaborator

Extract peer creation into spawnPeer(), which binds each peer to a fresh child context and retries NewPeer without cancelling that context on failure.

Both retry blocks previously created currentPeerCtx once and cancel()-ed it inside the retry on error. NewPeer starts its background goroutines only after all of its error paths, so a failed attempt has nothing to clean up while cancelling poisons the shared context: every subsequent retry (and the eventual live peer) then ran on an already-cancelled context and never received rmb calls until a manual restart.

Also unify the in-memory expiration to 6h on both the initial and the config-update reconnect paths (the constants were inverted: initial used 660 = 6 minutes labeled "1 hours", update used 660*60), and give each spawn its own backoff instead of sharing one instance across both paths.

Description

Describe the changes introduced by this PR and what does it affect

Changes

List of changes this PR includes

Related Issues

List of related issues

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstring

Extract peer creation into spawnPeer(), which binds each peer to a fresh
child context and retries NewPeer *without* cancelling that context on
failure.

Both retry blocks previously created currentPeerCtx once and cancel()-ed
it inside the retry on error. NewPeer starts its background goroutines
only after all of its error paths, so a failed attempt has nothing to
clean up while cancelling poisons the shared context: every subsequent
retry (and the eventual live peer) then ran on an already-cancelled
context and never received rmb calls until a manual restart.

Also unify the in-memory expiration to 6h on both the initial and the
config-update reconnect paths (the constants were inverted: initial used
6*60 = 6 minutes labeled "1 hours", update used 6*60*60), and give each
spawn its own backoff instead of sharing one instance across both paths.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ashraffouda
ashraffouda merged commit 7b0a1fd into main Jul 22, 2026
22 checks passed
@ashraffouda
ashraffouda deleted the fix-peer-creation branch July 22, 2026 13:38
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