Skip to content

feat: add optional AbortSignal to every public async method - #673

Open
ZacLou wants to merge 2 commits into
conduit-protocol:mainfrom
ZacLou:feat/abort-signal-all-methods-604
Open

feat: add optional AbortSignal to every public async method#673
ZacLou wants to merge 2 commits into
conduit-protocol:mainfrom
ZacLou:feat/abort-signal-all-methods-604

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses #604

Problem

Some methods threaded { signal }, others didn't. There was no consistent way for callers to cancel an in-flight operation.

Changes

StreamsModule (13 methods)

Added signal?: AbortSignal to: get, withdrawable, streamedTotal, withdraw, cancel, pause, resume, topUp, forceCancel, transferRecipient, clawback, estimateFee, list

FactoryModule (5 methods)

Added signal?: AbortSignal to: streamCount, streamAddress, streamsBySender, streamsByRecipient, protocolFeeBps

Internal helpers

  • _resolveAddr, _simulateTx, _invoke, and _sendAndPoll now accept signal
  • Abort check added at the start of each public method
  • Abort check added inside the _sendAndPoll polling loop so confirmation waits can be cancelled

Usage

const controller = new AbortController();

// Cancel after 10 seconds
setTimeout(() => controller.abort(), 10_000);

try {
  const stream = await sdk.streams.get(1n, controller.signal);
} catch (e) {
  if (e instanceof DOMException && e.name === 'AbortError') {
    console.log('Cancelled');
  }
}

Backward compatibility

signal is optional and defaults to undefined. All existing code continues to work unchanged.

Verification

  • Typecheck passes
  • All 989 tests pass (78 test files)

ZacLou and others added 2 commits September 5, 2026 22:45
Adds signal?: AbortSignal to all public async methods on StreamsModule
and FactoryModule, with an abort check at the start of each method and
in the _sendAndPoll polling loop. This gives callers a consistent way
to cancel any in-flight operation.

StreamsModule (13 methods):
  get, withdrawable, streamedTotal, withdraw, cancel, pause, resume,
  topUp, forceCancel, transferRecipient, clawback, estimateFee, list

FactoryModule (5 methods):
  streamCount, streamAddress, streamsBySender, streamsByRecipient,
  protocolFeeBps

Internal helpers _resolveAddr, _simulateTx, _invoke, and _sendAndPoll
also accept signal for deeper cancellation support.

Addresses conduit-protocol#604
@ZacLou
ZacLou force-pushed the feat/abort-signal-all-methods-604 branch from 4d69237 to da24857 Compare September 5, 2026 14:46
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.

2 participants