Skip to content

feat: add offline queue for mutating operations - #945

Merged
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
kingsrichie79-cmyk:feature/offline-queue
Sep 28, 2026
Merged

Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
kingsrichie79-cmyk:feature/offline-queue

Conversation

@kingsrichie79-cmyk

Copy link
Copy Markdown
Contributor

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.

- 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
@drips-wave

drips-wave Bot commented Sep 26, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Kingsman-99
Kingsman-99 merged commit 0a239df into Stellar-split:main Sep 28, 2026
1 check 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.

Add SDK offline queue — buffer mutations when RPC is unavailable

2 participants