Skip to content
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 handling of token error when first connecting. #986

Merged
merged 9 commits into from
Feb 27, 2020

Conversation

tcard
Copy link
Contributor

@tcard tcard commented Feb 13, 2020

Removed complex and apparently unnecessary logic on error protocol message handler. No tests broken by this.

I first thought this was an issue with RSA4b, so I also added a missing test for it and some documentation.

Fixes #984.

ricardopereira
ricardopereira previously approved these changes Feb 13, 2020
Soft-unwrapping catches assertion failures more gracefully.
Reconnection after DISCONNECTED and failing to establish a connection
due to token error follow similar but slightly different logics. It's
not worth trying to abstract it.

Now, per RTN14b, of connection establishment failure: "If  the attempt
to create a new token fails, or the subsequent connection attempt fails
due to another token error, then the connection will transition to the
DISCONNECTED state, and the Connection#errorReason should be set. (If no
means to renew the token is provided, RSA4a applies [ie. moves to
FAILED])"
Test that we actually went through CONNECTED, instead of going directly
to FAILED (that would be RTN14b).

Also, don't assert on the error message. Asserting on the code is
enough.
@tcard
Copy link
Contributor Author

tcard commented Feb 17, 2020

Bitrise: ❌

Well, it looks like one does not simply remove a bunch of lines.

No tests broken by this.

This is so false I don't know how I reached that conclusion originally. I've fixed a bunch of them, but for some reason there are tests for unrelated things such as presence, etc. that do seem broken by this (since they pass on master), I don't know how yet.

@SpencerCDixon
Copy link

Ouch :( Is this still on yalls radar to resolve 🤞?

@tcard
Copy link
Contributor Author

tcard commented Feb 23, 2020

@SpencerCDixon Yes, of course.

@SpencerCDixon
Copy link

Hey, @tcard sorry for being annoying but is there any chance you have a timeline on when this might get fixed and merged in?

I have a few weeks of work porting over to Ably that is being blocked by this. We'd like to start beta testing the integration but if Ably clients can't get new tokens when folks computers are asleep that's a nonstarter. Most of our users keep our app running 24/7 and their computers are likely asleep overnight and would miss refresh token windows.

Assuming our initial testing goes well we're going to be using your service with thousands of users and paying yall a lot of money 😄

Again, sorry to be annoying, I know you probably have a LOT going on just trying to get a handle on what I'll be working on next week and if I should be considering forking.

@tcard
Copy link
Contributor Author

tcard commented Feb 27, 2020

@SpencerCDixon I didn't realize this was such a blocker for your development, since it's almost ready to be released. We'll prioritize getting this released as soon as possible.

In any case, note that a workaround is possible by making a new connection each time the computer wakes up, passing the recoveryKey from the old connection in the new connection's ARTClientOptions.recover. That will recover the old connection's state if less that 2 minutes passed. But I think you can expect this to be released by tomorrow, so that won't be necessary. (But maybe it's good to have that trick up your sleeve anyway, in case you want to dispose of your ARTRealtime instance for some reason without losing state!)

@tcard
Copy link
Contributor Author

tcard commented Feb 27, 2020

After deeper review, it seems this change is fine after all. Test failures were coincidentally caused by the flakiness of the test suite.

@tcard tcard merged commit 0663a51 into master Feb 27, 2020
@tcard tcard deleted the 984-fix-token-error-connect branch February 27, 2020 13:21
@SpencerCDixon
Copy link

Awesome, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Auth token refresh misses when macOS is sleeping
4 participants