feat: add offline queue for mutating operations - #945
Merged
Kingsman-99 merged 2 commits intoSep 28, 2026
Merged
Conversation
- Added OfflineQueue to buffer mutating calls when RPC is down - Supports queuing pay, release, and cancel - Added getOfflineQueue and clearOfflineQueue methods - Drains queue on successful checkRPCHealth - Added tests for size enforcement and localStorage persistence
|
@kingsrichie79-cmyk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #886
PR Description
This PR introduces an offline queue for StellarSplitClient that intercepts and buffers mutating calls when the Soroban RPC is unreachable.
Implementation Details:
OfflineQueue Module: Manages queueing logic (maxQueueSize), in-memory buffering, persistence to localStorage (persistToStorage), and flushing.
Client Methods (getOfflineQueue(), clearOfflineQueue()): Added to StellarSplitClient to allow consumers to read or discard the current state.
Interception Logic: Wraps operations (pay()) and injects missing mutating method stubs (release(), cancel()). When triggered and the checkRPCHealth resolves to "down", the queue swallows the invocation (to prevent the app from crashing) and buffers it, returning { txHash: "queued" }.
Automatic Recovery: checkRPCHealth now automatically checks if the queue has pending operations upon detecting a successful health check (health.status !== "down"). The queue is drained sequentially and operations emit queue:operation:failed or queue:drained.
Tests: Full test coverage inside test/offlineQueue.test.ts to simulate RPC failure (queue filling up, size eviction) and successful RPC recovery (successful draining), as well as verification of mocked localStorage persistence.