Skip to content

Show an error message if resetting identity takes too long - #34715

Closed
andybalaam wants to merge 8 commits into
developfrom
andybalaam/timeout-on-resetEncryption
Closed

Show an error message if resetting identity takes too long#34715
andybalaam wants to merge 8 commits into
developfrom
andybalaam/timeout-on-resetEncryption

Conversation

@andybalaam

@andybalaam andybalaam commented Aug 14, 2026

Copy link
Copy Markdown
Member

Exposes the error that is happening in #34642 but doesn't fix it:

If we take longer than 5 seconds to reset identity, we show this:

image

and log this:

Failed to reset identity: Timed out

... which is better than what we did before, which was to freeze forever on the "resetting digital identity" screen.

Checklist

Comment thread apps/web/src/components/views/settings/encryption/ResetIdentityBody.tsx Outdated
@andybalaam

Copy link
Copy Markdown
Member Author

This is now ready for review again, after some github-down-faffing.

@richvdh richvdh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Some low-importance comments.

// clicked again, and warn the user not to close the window.
const [inProgress, setInProgress] = useState(false);

async function onClick(): Promise<void> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shouldn't this and doOnClick have a useCallback ?

await act(async () => panel.getByRole("button", { name: "Continue" }).click());

// And wait more than the timeout
await sleep(10);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rather than sleeping in a test, and threading a timeout value through 10 layers of components, could we use fake timers?

const client = MatrixClientPeg.safeGet();

// Given reset will freeze forever when we do it
client.getCrypto()!.resetEncryption = vi.fn().mockImplementation(() => sleep(20000));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"A promise that never resolves" can also be spelt new Promise(() => {}), which might be better than having a dangling timeout?

@t3chguy

t3chguy commented Aug 19, 2026

Copy link
Copy Markdown
Member

So 5s seems not a very long time for someone on a poor connection, additionally the error makes it sound guaranteed that it failed, which might not be true given the flow doesn't actually get cancelled - so it may continue running in the background after the error?

Also looking at the doc comment for resetEncryption it seems to deal with UIA, surely anyone going through UIA will take more than 5 seconds?

@andybalaam

Copy link
Copy Markdown
Member Author

We had a conversation within the Crypto team about whether this is actually better than just freezing, since the freezing does demonstrate to the user that something went wrong.

If I add on doubts expressed by t3chguy, I think I will abandon this and leave it as it is. The underlying bug is fixed by matrix-org/matrix-js-sdk#5485

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants