Skip to content

Fix stale NodeProxy reconnect state - #31

Merged
dominicletz merged 1 commit into
mainfrom
fix/node-proxy-stale-reconnect
Sep 4, 2026
Merged

dominicletz merged 1 commit into
mainfrom
fix/node-proxy-stale-reconnect

Conversation

@dominicletz

@dominicletz dominicletz commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Clear cached lastblocks entries when NodeProxy removes a primary or fallback WSConn.
  • Prevent a fresh reconnect from inheriting a stale URL timestamp.
  • Add regression tests for primary URL reuse and fallback cleanup.

Tests

  • mix lint
  • mix format --check-formatted
  • DIODE_MINIMAL_TEST=1 mix test --no-start test/remote_chain/ (137 passed)
  • DIODE_MINIMAL_TEST=1 mix test --no-start test/remote_chain/node_proxy_test.exs (39 passed)
  • Full minimal suite is blocked because WALLETS is unset during test compilation.

Note

Medium Risk
Touches connection teardown and staleness eviction in NodeProxy, which affects which RPC providers stay in the pool; change is narrow and well-covered by regression tests.

Overview
Fixes reconnect eviction where a new WebSocket for the same URL was treated as stale because lastblocks timestamps are keyed by URL, not process id.

When remove_connection/2 drops a primary or fallback WSConn, it now collects the affected URLs (including fallback_url when the fallback dies) and Map.drops those keys from lastblocks, so a replacement connection does not inherit the old provider’s stale block time.

Tests assert fallback lastblocks cleanup on stale fallback eviction, add a regression for “evict stale → reconnect same URL → fresh conn stays in pool,” and factor WSConn stubs through stub_data_connection/1.

Reviewed by Cursor Bugbot for commit b00159a. Configure here.

Co-authored-by: Cursor <cursoragent@cursor.com>
@dominicletz
dominicletz merged commit dc7d6aa into main Sep 4, 2026
2 checks passed
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