Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix spurious session corruption error #12280

Merged
merged 7 commits into from
Feb 26, 2024

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Feb 22, 2024

Move the server versions check to each time we reconnect to the server rather than the first time,although, as per comment it will still only trigger the first time, but it will avoid us awaiting and mean we know we're connected to the server when we try, and get automatic retries.

Fixes element-hq/element-web#26967

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

Move the server versions check to each time we reconnect to the server
rather than the first time,although, as per comment it will still only
trigger the first time, but it will avoid us awaiting and mean we know
we're connected to the server when we try, and get automatic retries.

Fixes element-hq/element-web#26967
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit troubled that we don't have playwright tests to check how this actually behaves in practice, but again I'll not insist on any for now, given it's meant to be a quick fix.

src/stores/LifecycleStore.ts Outdated Show resolved Hide resolved
Comment on lines 92 to 95
// Note that although we do this on a reconnect, we cache the server's versions in memory
// indefinitely, so it will only ever trigger the toast on the first connection after a fresh
// restart of the client.
if (await client.isVersionSupported(version)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's rather odd that we (sometimes) make another /versions request, rather than using the result of the /versions request that the client has just successfully done, which caused the transition to the Syncing state.

I appreciate that changing that would mostly mean changes in the js-sdk (in the implementation of isVersionSupported, I guess), so I'm not asking you to change this now as part of a quick fix to this issue, but maybe you could record the situation in a comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the js-sdk impl also laments the lack of cache expiration which seems roughly in the same category of problems. I can put a comment there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think it does always re-use the result of the /versions request since it caches the response and of course, in this case, we know it's already done one so it never actually does the request. Noted in 8616cc2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/stores/LifecycleStore.ts Show resolved Hide resolved
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits as above

Comment on lines 97 to 98
// restart of the client (which has just happened since it's started syncing, so this should
// never actually cause a request).)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's accurate. Or rather, it's accurate, but not for the reason given. The sync loop doesn't populate the serverVersionsPromise which is used by isVersionSupported.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, in my brief investigation it appeared to only do a single request, but not 100% sure so I've just removed that bit of the comment.

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks ok except for the misleading comment

Co-authored-by: Richard van der Hoff <[email protected]>
@dbkr dbkr added this pull request to the merge queue Feb 26, 2024
Merged via the queue into develop with commit 1403cd8 Feb 26, 2024
22 checks passed
@dbkr dbkr deleted the dbkr/fix_bogus_session_restore_error branch February 26, 2024 15:51
@dbkr dbkr added the backport staging Label to automatically backport PR to staging branch label Feb 26, 2024
RiotRobot pushed a commit that referenced this pull request Feb 26, 2024
* Fix spurious session corruption error

Move the server versions check to each time we reconnect to the server
rather than the first time,although, as per comment it will still only
trigger the first time, but it will avoid us awaiting and mean we know
we're connected to the server when we try, and get automatic retries.

Fixes element-hq/element-web#26967

* Move test & add regression test

* Write some more tests

* More comments & catch exceptions in server versions check

* Note caching behaviour

* Typo

Co-authored-by: Richard van der Hoff <[email protected]>

* Remove the bit of the comment that might be wrong

---------

Co-authored-by: Richard van der Hoff <[email protected]>
(cherry picked from commit 1403cd8)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport staging Label to automatically backport PR to staging branch T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems
Projects
None yet
3 participants