Skip to content

Fix #416: Deduplicate stream addresses in cancel_batch_streams - #478

Open
chiemezie1 wants to merge 1 commit into
conduit-protocol:mainfrom
chiemezie1:fix/416-cancel-batch-dedup
Open

Fix #416: Deduplicate stream addresses in cancel_batch_streams#478
chiemezie1 wants to merge 1 commit into
conduit-protocol:mainfrom
chiemezie1:fix/416-cancel-batch-dedup

Conversation

@chiemezie1

Copy link
Copy Markdown

Fix #416: Deduplicate stream addresses in cancel_batch_streams

Problem

DripFactory::cancel_batch_streams didn't deduplicate stream_addresses, causing panics when a duplicated address was passed.

If a caller accidentally passes the same stream address twice (e.g., building the list from an unfiltered selection), the first cancel succeeds and sets FLAG_CANCELLED. The second cancel on the now-cancelled stream returns Error::StreamCancelled, which the non-try_ variant turns into a panic, reverting the entire batch. Every other cancellation in the same call is rolled back.

Solution

Deduplicate stream_addresses before cancelling. Each unique stream is cancelled exactly once, degrading accidental duplicates to a no-op for that entry instead of failing the whole batch.

Changes

  • Add deduplication logic in cancel_batch_streams() to build unique_addresses vector
  • Add regression tests in tests/factory_batch_cancel.rs:
    • regression_duplicate_stream_addresses_cancel_without_panic: Simulates the dedup behavior with duplicate addresses
    • stream_cancel_twice_fails_gracefully: Verifies the underlying behavior that causes batch failures

Testing

✅ All factory unit tests pass (32 passed)
✅ Regression tests pass (2 passed)
✅ No existing tests broken

Closes: #416

…h_streams

Issue conduit-protocol#416: cancel_batch_streams didn't deduplicate stream_addresses, causing
panics when a duplicated address was passed. If a caller accidentally passes the
same stream address twice (e.g., building the list from an unfiltered selection),
the first cancel succeeds and sets FLAG_CANCELLED. The second cancel on the now-
cancelled stream returns Error::StreamCancelled, which the generated non-try_
DripStreamClient::cancel turns into a panic, reverting the entire batch.

Solution: Deduplicate stream_addresses before cancelling. Each unique stream is
cancelled exactly once, degrading accidental duplicates to a no-op for that entry
instead of failing the whole batch.

Changes:
- Add deduplication logic in cancel_batch_streams to build unique_addresses
- Add regression tests in tests/factory_batch_cancel.rs:
  * regression_duplicate_stream_addresses_cancel_without_panic: Simulates the
    dedup behavior with duplicate addresses
  * stream_cancel_twice_fails_gracefully: Verifies the underlying behavior that
    causes the batch failure
@chiemezie1
chiemezie1 requested a review from Jaydbrown as a code owner August 31, 2026 09:44
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@chiemezie1 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

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.

Bug: DripFactory::cancel_batch_streams doesn't dedupe stream_addresses — a duplicated address panics the whole batch on the second cancel

2 participants