-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
Stop keep alive when sync is aborted #3686
Stop keep alive when sync is aborted #3686
Conversation
…pSync() to prevent endeless looping
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.
Thank you for the contribution!
However... I don't really understand this, and it seems dangerous.
First of all, please can you explain the code path more clearly. Why is an AbortError
thrown in this situation? I'm not very familiar with this area of the code, I'm afraid. In any case, the new code needs more comments to explain what is going on.
Second: how can you be sure that this is the only reason that an error like this will be thrown? I note that the code that handles regular /sync
requests doesn't do anything like this. Instead, it checks this.running
(
Line 1038 in a33edb2
if (!this.running) { |
Third: please do add some tests for this case, otherwise there is a high chance of a regression. I think the best place is spec/integ/matrix-client-syncing.spec.ts
.
@finsterwalder Also: I see that you have ticked the box for "Sign-off given on the changes" but I don't see your sign-off here. Please do read CONTRIBUTING.md for details on the DCO process. |
Signed-off-by: Malte Finsterwalder <[email protected]>
…terwalder/matrix-js-sdk into stop_keepAlive_when_sync_is_aborted
Thanks for checking my PR so quickly. The code path is as follows. But you are right. I added a sign-off now. I did that on a different branch and then forgot it. ;-) I looked into the test file, but I didn't see any tests, that check the keep alive feature. |
if (!this.running) { | ||
clearTimeout(this.keepAliveTimer); | ||
if (this.connectionReturnedDefer) { | ||
this.connectionReturnedDefer.reject(); | ||
this.connectionReturnedDefer = undefined; | ||
} |
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.
In any case, the new code needs more comments to explain what is going on.
please do give this code some comments to explain what it is doing. Imagine you are unfamiliar with this code and trying to understand it. When does it happen, why is this the right thing to do? Are there other places in this file that have similar logic that it might be helpful to link to?
I see a sign-off on one of the commits in this PR, but not the ones with all the new code! Best thing to do is to update the description of the PR to show that your signoff covers all the changes in the PR. |
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.
I looked into the test file, but I didn't see any tests, that check the keep alive feature.
That's quite a task for me to get acquainted enough to write such a test for the first time...
I talked to some other members of the team. We're agreed that we should not make an exception from our policy that all changes should include tests, and we think it's important that this change be tested. We don't feel like we can land it without tests.
It doesn't have to be a perfect test - all we're looking for is something that fails before your change, and passes afterwards.
I'm sorry that the existing code is not well tested, and I'm also sorry that nobody is in a position to give better guidance on writing a new test.
Ok. Good points. I will add documentation. Thinking about my problem a little more, I have some ideas for followup improvements. Was wondering, what you think about it: This is a keepAlive, which keeps retrying the call to the matrix server. When I stop the sync, the retry should obviously stop. That's what my fix is about. |
You're probably right that there are lots of other calls that aren't worth retrying. However: One problem is that, as things currently stand, the spec (https://spec.matrix.org/v1.8/client-server-api/#get_matrixclientv3sync) has very little to say about which error codes might be returned, and what you can infer from them. A second problem: what should we actually do on one of these errors? If we just stop the sync loop, it just leaves the user with a dead client. Should we raise a So we might be able to improve this, but I strongly recommend focussing on |
I understand that including other cases would need a little more thinking. I just wanted to raise awareness and start this discussion. The 401 case is currently notified via the HttpApiEvent.SessionLoggedOut event, so there exists a possible handling strategy. And it's also clear, that this will not fix itself with retries. Would it make sense to include this case soon? |
It was easier to create a new, clean Pull Request: #3720 |
Type: [defect]
T-Defect
This PR solves issue: #3678
When you start a client, which has connection problems, a keepAlive is started.
But when the connection is actively stopped e.g. via calling stopSync(), the connection is aborted.
When the connection is aborted, it does not make sense to continue to try to connect, because it will never succeed.
This is solved by this PR.
I could not find any tests for the sync, so I didn't find a place to extend tests to check this special case.
Checklist
Here's what your changelog entry will look like:
✨ Features