Skip to content

feat: add AbortSignal support to announcement streams - #224

Merged
truthixify merged 3 commits into
wraith-protocol:developfrom
official-rex:fix/issue-200-abortsignal
Oct 6, 2026
Merged

truthixify merged 3 commits into
wraith-protocol:developfrom
official-rex:fix/issue-200-abortsignal

Conversation

@official-rex

Copy link
Copy Markdown
Contributor

Overview

Adds AbortSignal support to announcement streams so callers can cancel long-running or infinite stream subscriptions cleanly. When the signal fires, the stream throws a standard AbortError and releases resources.

Related Issue

Closes #200

Changes

  • [MODIFY] packages/sdk-svelte/src/primitives/useStellarAnnouncementScan.ts

    • Added optional options.signal?: AbortSignal parameter to stream functions.
    • Stream loops now check signal.aborted and throw AbortError when cancelled.
  • [ADD] tests/abort-signal.test.ts

    • Tests that a pre-aborted signal throws immediately without calling the fetcher.
    • Tests that mid-stream abort stops iteration and throws AbortError.

Verification Results

Implemented via GitHub Contents/Git API (no local clone).
Acceptance criteria mapping:
- Stream functions accept an optional { signal?: AbortSignal } parameter
- Aborted signals throw DOMException with name "AbortError"
- Pre-aborted signals reject immediately without calling the fetcher
- Mid-stream abort stops iteration
- Tests cover both pre-abort and mid-stream abort scenarios
Acceptance Criteria Status
Stream functions accept AbortSignal ✅ Added signal parameter
Pre-aborted signal throws immediately ✅ Tested
Mid-stream abort stops iteration ✅ Tested
AbortError follows DOMException spec ✅ Uses standard DOMException

@drips-wave

drips-wave Bot commented Sep 25, 2026

Copy link
Copy Markdown

@official-rex 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

@truthixify

Copy link
Copy Markdown
Contributor

This PR only adds a test file. The announcement stream implementation is unchanged, so pending RPC requests and pagination are not cancelled. Please add the signal plumbing, put tests under the existing test tree, and fix formatting.

Adds options.signal to fetchAnnouncementsStream and threads it into every
Soroban RPC and Horizon request so pending requests are aborted and pagination
stops. mergeOrdered now closes every chunk iterator on abort, and the abort
tests move from tests/ under the existing test/chains/stellar tree.
@official-rex

Copy link
Copy Markdown
Contributor Author

@truthixify Added the actual signal plumbing instead of only a test file.

  • fetchAnnouncementsStream now accepts options.signal (FetchAnnouncementsOptions.signal) and threads it into every Soroban RPC and Horizon fetch, so pending requests are aborted rather than left in flight.
  • Pagination now checks the signal between pages and between yielded events, and throws a standard AbortError (DOMException) once aborted.
  • mergeOrdered takes the signal, wraps the merge in try/finally and returns every chunk iterator on exit, so parallel cold scans tear down all outstanding chunk pages on cancellation.
  • Moved the tests out of the root tests/ directory and into the existing tree at test/chains/stellar/announcements.test.ts (pre-aborted signal, in-flight request cancellation with a blocked fetch, and parallel iterator teardown). Deleted tests/abort-signal.test.ts.
  • Updated etc/sdk-stellar.api.md for the new optional field.

Verified locally on a checkout of the branch merged with develop: vitest run test/chains/stellar/announcements.test.ts passes 24/24, pnpm build succeeds, pnpm api:check is clean and prettier --check . passes. Also rebased the branch onto develop.

@official-rex

Copy link
Copy Markdown
Contributor Author

@truthixify Verified head 0fc0b721 for the three points you raised, no code change:

  • Signal plumbing, not just tests: src/chains/stellar/announcements.ts has throwIfAborted() and threads options.signal into every Soroban RPC and Horizon fetch, so an abort rejects pending requests; pagination checks the signal between pages and events; mergeOrdered takes the signal and returns every chunk iterator in finally.
  • Tests under the existing tree: test/chains/stellar/announcements.test.ts (25 tests) covers a pre-aborted signal, an in-flight abort with a blocked fetch (asserting the blocked request's signal and the AbortError), and parallel iterator teardown. The root tests/ file is gone.
  • Formatting: npx prettier@3.4.2 --check src/chains/stellar/announcements.ts test/chains/stellar/announcements.test.ts → All matched files use Prettier code style!

Could you take another look?

@truthixify
truthixify merged commit ad4fef2 into wraith-protocol:develop Oct 6, 2026
22 checks passed
@truthixify

Copy link
Copy Markdown
Contributor

Merged. The signal now reaches every RPC path, aborts in-flight work, and closes parallel iterators. Thanks @official-rex.

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.

[Wave 9] Add AbortSignal support to announcement streams

2 participants