Implicit attach on channel.objects.get() call#472
Conversation
Review against ably-js implementationI've cross-checked this PR against ably-js 🟠
|
| State | Behaviour |
|---|---|
ATTACHED, SUSPENDED |
Pass through; do not re-attach. |
INITIALIZED, DETACHED, DETACHING, ATTACHING |
Implicit attach and wait. |
FAILED |
Throw ErrorInfo 400/90001. |
🟠 Behaviour during pending implicit-attach if the channel transitions to FAILED
RTO1e says "implicitly attach the RealtimeChannel and wait for the attach to complete" but doesn't define what happens if the attach attempt itself fails, or if the channel transitions to FAILED during the wait. The impl simply propagates the attach() rejection (realtimechannel.ts:1144 → standard attach() failure semantics).
Worth being explicit:
- (RTO1e1) If the implicit attach fails (e.g. the channel transitions to `FAILED` during the wait), the returned promise MUST reject with an `ErrorInfo` 400/90001.
🟡 RFC 2119 keyword precision
(RTO1f) says "the library should throw" — should this be MUST? The pre-existing (RTO1b) used the same "should" wording, but per CLAUDE.md's writing principles ("Use RFC 2119 keywords precisely"), throwing for a FAILED channel is a hard requirement. Suggest "MUST throw".
⚪ Minor: cross-reference to RTL27 lifecycle
For readers landing on this clause without context, a one-line cross-reference to channel-state transitions (RTL2) and the implicit-attach pattern used elsewhere (e.g. RTP11b for presence.get(), mentioned in the PR description) would help with consistency framing.
These observations correspond to issue B-3 in LIVEOBJECTS_SPEC_REVIEW.md (cross-branch review) and Task B-6 in LIVEOBJECTS_UPDATE_SPEC_ACTIONABLE_PLAN.md.
07e89c9 to
969aade
Compare
There was a problem hiding this comment.
LGTM.
Addressed changes as per review comment and now behaviour is exactly similar to JS code.
969aade to
b5d9a12
Compare
b5d9a12 to
2c9b91b
Compare
b0638be to
0d680ca
Compare
0d680ca to
582f2e2
Compare
df46e4e to
d166566
Compare
channel.objects.getRoot() callchannel.objects.get() call
| - `(RTL32d)` On success, returns an `UpdateDeleteResult` object containing the version serial of the published update, obtained from the first element of the `serials` array of the [TR4s](#TR4s) `res` field of the `ACK`. Indicates an error if the operation was not successful. | ||
| - `(RTL33)` *Ensure-active-channel* internal procedure. When invoked, the SDK MUST inspect the current state of the `RealtimeChannel` (see [RTL2](#RTL2)) and proceed as follows: | ||
| - `(RTL33a)` If the channel is in the `ATTACHED` or `SUSPENDED` state, the procedure completes immediately without performing any attach. | ||
| - `(RTL33b)` If the channel is in the `INITIALIZED`, `DETACHED`, `DETACHING`, or `ATTACHING` state, perform an implicit attach per [RTL4](#RTL4) and wait for it to complete |
There was a problem hiding this comment.
This is a behavioural change compared to RTP11b i.e. a DETACHED channel now gets implicit attach, instead of throwing an error. Our docstrings aren't specific about the circumstances in which an implicit attach gets performed so I think we can get away with it, and I don't see any obvious reason why we wouldn't want to do it, but I thought it worth pointing out.
There was a problem hiding this comment.
This behaviour follows current ably-js implementation -> #472 (comment)
There was a problem hiding this comment.
This behaviour follows current ably-js implementation
Sure, I get that; I'm saying that the ably-js implementation is different to the spec and it's not obvious that the ably-js behaviour is the one that we want (but that it's minor)
e305f50 to
c5627f8
Compare
|
LGTM, I can't approve because it's my PR, but approved |
Adds a shared *ensure-active-channel* procedure (RTL33) that consolidates implicit-attach behaviour, and references it from `RealtimeObject#get` (RTO23e) and `RealtimePresence#get` (RTP11e) to avoid spec duplication. As already implemented in JS in 9bde15e. Co-Authored-By: Andrew Bulat <andrii.bulat@gmail.com> Co-Authored-By: Lawrence Forooghian <lawrence.forooghian@ably.com>
c5627f8 to
cd5fe10
Compare
As already implemented in JS in ably/ably-js@9bde15.
Split out of #427 since it's a standalone behaviour.