-
Notifications
You must be signed in to change notification settings - Fork 25
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
Fix RTN20. #444
Fix RTN20. #444
Conversation
} | ||
// let stateChange = stateChange! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to be commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, sorry, leftover. Fixed at 65bfc55.
LGTM |
3fa63a8
to
864650e
Compare
d1bc9b9
to
e71b852
Compare
@mattheworiordan I rebased it with master. |
Yes, please force push. Are any other tests failing? |
@mattheworiordan Yes, there is at least one test failing with something related with this PR:
|
aeae1e2
to
c78004f
Compare
@ricardopereira well from the title of that test, it should raise an incompatible credentials error I believe, so it sounds like that is a test that genuinely needs to be fixed then. |
@mattheworiordan The test is fine. I made a fix and it is running now. |
- (void)listenForHost:(NSString *)host callback:(void (^)(BOOL))callback { | ||
[self off]; | ||
|
||
if (!host) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would host
be nil here? If it's because the user provides a nil host, this validation should happen at a higher level, where the user provides it, and properly return an error to the user (probably as an exception). Internal code can just assume then that host
is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tcard It makes sense what you said but I think this check is important to help out when you're debugging. The host
was nil because the transport
was nil. Now, why was the transport
nil? I don't know. I need to check the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for the sake of clarification: the transport
is nil because the client transitions to FAILED
, see https://github.com/ably/ably-ios/blob/4f1bd1098c54663ce20cf3dfb7b4595f4fbe4b40/Source/ARTRealtime.m#L302.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tcard I'm sure you faced something similar when you run the test suite on your machine.
The force cast of a transport
like realtime.transport as! TestProxyTransport
sometimes raises a bad access because the realtime.transport
is created only when the connection starts CONNECTING, so we need to guarantee that the current connection has a valid transport instance before force casting it. The test suite will stall when a EXC_BAD_ACCESS
occurs.
Then we have as well situations like this:
Just for the sake of clarification: the
transport
is nil because the client transitions toFAILED
, see https://github.com/ably/ably-ios/blob/4f1bd1098c54663ce20cf3dfb7b4595f4fbe4b40/Source/ARTRealtime.m#L302.
What is your opinion on creating the transport
once and release it only when the RealtimeClient
deinitialise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I don't know how much that would affect things, but I suspect we would be fixing the wrong problem. If we're trying to use the transport when there is no transport, forcing a transport to be there even when there's no connection will probably just move the failure elsewhere.
Instead, things requiring a transport should make sure that there's indeed a transport present I think.
Why does the client transition to FAILED?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICS that doesn't fix the underlying issue, just improves error reporting (which is good, but that's the kind of changes I was talking about here arguing that they're not critical right now.)
If we have a test in which the transport is unexpectedly nil, why not fix it so that the transport is not nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tcard Yes, you're right. The error reporting is another discussion.
The transport is unexpectedly nil because when the client connects, the _transport
is nil but the instance is created and starts the connection, then the _transport
emits the Failed state because of the incompatible client, the ARTRealtimeFailed
is handled and the _transport
is cleared, then comes the _reachability listenForHost:[_transport host]
and _transport
is nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tcard Now, when is the right moment to start listening for a host?
IMO, if the connections fails immediately then it doesn't makes sense to start listening for a host. So, if there is no transport at the moment when the client is setting up the OS reachability, then ignore it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then comes the _reachability listenForHost:[_transport host] and _transport is nil.
I guess you mean that [_transport host]
is nil? _transport
cannot be nil at this point since it's instantiated right above.
Now, why is [_transport host]
nil? That surely looks like a inconsistent state of _transport
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tcard No, I mean _transport
is nil. The connection will emit a Failed state and set _transport
to nil.
Specs:
Failed:
Same failures comparing with #467. |
@tcard @mattheworiordan Ready to be reviewed. |
LGTM |
I've tested the ARTOSReachability "live" manually (by switching on/off
the real Internet connection on my machine) and it works as expected,
but it needs #385 to properly handle transport errors.