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

Session expiration is not handled gracefully by client #1472

Open
2 tasks done
jonathanperret opened this issue Feb 21, 2025 · 1 comment
Open
2 tasks done

Session expiration is not handled gracefully by client #1472

jonathanperret opened this issue Feb 21, 2025 · 1 comment
Labels

Comments

@jonathanperret
Copy link
Collaborator

Describe the current behavior

If a document is open while your Grist session expires (due to COOKIE_MAX_AGE), you can currently continue to edit the document seemingly normally, and the changes are correctly persisted.

You will only have to sign in again if you navigate away from the document, i.e. by returning to the workspace.

This is clearly enabled by the fact that most document operations go through a WebSocket and session validity is only checked when opening the WebSocket.

But some document operations, such as renaming the document, modifying access rules, listing snapshots… do not go through the WebSocket and will fail in that situation.

The Grist client code unfortunately does not handle such failures gracefully: an error message may pop up without obvious recourse, or the entire page may go blank with an error popup.

Additionally, when a document reload is triggered by another user modifying the access rules, or by the loss of the WebSocket connection due to network conditions or a doc worker restart, the document is not reloaded properly, showing an error instead.

Steps to reproduce

  1. Sign in to a Grist instance (such as getgrist.com) and open a document
  2. Clear the associated cookies (on getgrist.com,grist_sid_prod) from your browser
  3. Observe that you can still edit the document, formulas correctly recalculate, etc.
  4. Try to rename the document: observe that the operation fails and an access denied toast appears in the bottom left.
  5. Go to Access Rules, make any change and click Save: observe that the page goes blank with a generic error popup. Note that the popup is unnecessarily worrying because the user only needs to reauthenticate for the document to load correctly. Also, clicking outside that popup leaves the user on an almost blank page.
Image

Describe the expected behavior

Whenever a call to the server is made that fails because of an expired or invalid session, the user should be prompted to reauthenticate (which may automatically succeed in the case of an existing SSO session).

Where have you encountered this bug?

Instance information (when self-hosting only)

No response

@dsagal
Copy link
Member

dsagal commented Feb 22, 2025

This is a very good description and explanation of the problem, thank you!

For anyone looking into fixing it, I wanted to point out another problem with similar symptoms. A user can sign into Grist with multiple accounts (using the "Add account" option in the user menu). For example, I am often logged in with both work and personal email addresses. Which account is active is a setting that's associated with each org, and saved in the user session. If I am logged in as A in one tab, and then in another tab for the same org, I switch my account to B, then a document that has been open in the first tab will continue working over the websocket, but operations that make new calls to the server may fail with confusing errors (as for an expired session), because the server will interpret them as made by account B, which may not even have access to this document. The solution may not overlap with than for expired sessions, but I wanted to point it out in case it does.

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

No branches or pull requests

2 participants