Skip to content

2.5 Why isn't it required to cancel the active Subscription? #317

Closed
@anthonyvdotbe

Description

@anthonyvdotbe

Rule 2.5 states: A Subscriber MUST call Subscription.cancel() on the given Subscription after an onSubscribe signal if it already has an active Subscription.

Why doesn't it additionally state that the Subscriber MUST call Subscription.cancel() on the active Subscription as well?

Say I have Subscriber S, with an active Subscription for Publisher P1. Now if Publisher P2 invokes onSubscribe on S:

  • S MUST cancel the Subscription for P2 (rule 2.5)
  • but P2 is still allowed to send S an onComplete or onError signal, even though S never called request on its Subscription (rules 2.9 and 2.10)
  • now suppose P2 sends an onError signal, this causes several issues:
    • S has no way of knowing whether this signal comes from P1 or P2, so what should it do?
    • P1 may later send an onComplete/onError signal, thereby further confusing S
    • the onError signal may arrive concurrently with another signal from Publisher P1, causing thread-safety issues

So I believe that, as soon as onSubscribe is invoked on a Subscriber with an active Subscription, the Subscriber is broken and both the new and active Subscription must immediately be cancelled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions