-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reconsider criteria for a channel ATTACHED
to be considered a contributor discontinuity
#239
Comments
This fixes an intermittent crash ("Non-initial ATTACHED state change with resumed == false should have a reason") in the integration tests which happened because the manager sometimes processed the initial ATTACHED contributor state change after the `attach()` call completed. I’ve followed my first suggestion in [1] for how to address this. Resolves #121 [1] ably/specification#239
This fixes an intermittent crash ("Non-initial ATTACHED state change with resumed == false should have a reason") in the integration tests which happened because the manager sometimes processed the initial ATTACHED contributor state change after the `attach()` call completed. I’ve followed my first suggestion in [1] for how to address this. Resolves #121. [1] ably/specification#239
The other aspect is: do we want to register a discontinuity on a feature if the channel that powers it has never successfully completed an attach operation?
RTL12 unfortunately is laxer on this - says "if any". So whilst I'd hope that any discontinuity event would have an error, the protocol doesn't guarantee it.
It is a guarantee in JS - as the event listeners are executed in order, meaning that the state monitor will be called before the listener registered in relation to the
At the moment at least (I am thinking about this more broadly atm) - we raise discontinuities if you explicitly detach a room and then bring it back again. I want to revisit this, but at the moment this wouldn't work for that reason (as reason would be nil in these cases). That said, I think a rewording of WDYT? |
Yeah, that logic makes sense.
Thanks for pointing these out; sounds like I need to remove the assertion failure that the Swift SDK currently has if you are meant to emit a discontinuity but there isn't an accompanying error.
So, the way this is currently implemented in Swift, at least, is that to a rough approximation there are two separate threads; one to process state changes and one that calls
(I’m sure there are ways of writing this where you don't run into this issue, but the pattern I’ve described is the one that Swift’s concurrency features kind of naturally lead you — well, naturally led me — to employ.)
That would make my life easier 🙂 |
Although the JS SDK allows users to be notified of a discontinuity without an associated error, when I copied the public API across in 20e7f5f I decided that this was probably unintentional and that we could do better (i.e. that surely every discontinuity has an error). However, in [1] Andy has pointed out at least a couple of ways in you might have a discontinuity without an error. Namely: 1. RTL12 does not guarantee that an UPDATE with resumed == false has an accompanying error 2. > we raise discontinuities if you explicitly detach a room and then > bring it back again So, allow discontinuities without an associated error. [1] ably/specification#239 (comment)
Although the JS SDK allows users to be notified of a discontinuity without an associated error, when I copied the public API across in 20e7f5f I decided that this was probably unintentional and that we could do better (i.e. that surely every discontinuity has an error). However, in [1] Andy has pointed out at least a couple of ways in you might have a discontinuity without an error. Namely: 1. RTL12 does not guarantee that an UPDATE with resumed == false has an accompanying error 2. > we raise discontinuities if you explicitly detach a room and then > bring it back again So, allow discontinuities without an associated error. [1] ably/specification#239 (comment)
Tweaking the existing criteria…
Here, I think that we’re trying to deal with the fact that a channel’s initial
ATTACHED
state change hasresumed == false
even though this state change does not represent a discontinuity in channel messages.However, CHA-RL4a2’s criterion for deciding which
ATTACHED
state change is the initial one assumes that the room will process the channel’s firstATTACHED
status change before the caller ofattach()
regains control and updates the room’s internal state to mark the contributor as successfully-attached. I don't think that this is necessarily a valid assumption. Hence, we might end up thinking that the initialATTACHED
actually represents a discontinuity.So, I think that the lightest-touch approach to fix CHA-RL4a2 is to use a different criterion for deciding whether the channel has already been attached; namely whether an
ATTACHED
state change has previously been received on that channel.(Update: For consistency we'd probably also want to update the criteria of CHA-RL4b1, too.)
…or reconsidering the criteria
But, I wonder if there’s an easier way to decide which
ATTACHED
channel state changes represent a discontinuity. My reading of RTN15c is that all discontinuity state changes will be accompanied by an error, so couldn’t we instead say that anATTACHED
state change is a discontinuity if it hasresumed == false
andreason != nil
? This would also allow us to tighten up the JSdiscontinuityDetected(…)
API to make its argument non-optional.The text was updated successfully, but these errors were encountered: