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

Check for liveliness on submission when the server was previously dead #3218

Merged
merged 2 commits into from
Jul 15, 2019

Conversation

turt2live
Copy link
Member

Fixes element-hq/element-web#10017

Specifically the return at the end of the diff fixes the problem, but it seems worthwhile to check for liveliness when we know the server has been dead in previous attempts.

Fixes element-hq/element-web#10017

Specifically the `return` at the end of the diff fixes the problem, but it seems worthwhile to check for liveliness when we know the server has been dead in previous attempts.
@turt2live turt2live requested a review from a team July 15, 2019 05:24
Copy link
Contributor

@bwindels bwindels left a comment

Choose a reason for hiding this comment

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

lgtm, just 1 thing to look at.

busy: false,
...AutoDiscoveryUtils.authComponentStateForError(e),
});
if (this.state.serverErrorIsFatal) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume serverErrorIsFatal comes from authComponentStateForError above. setState may not immediately modify this.state so keeping the result from authComponentStateForError in a local var to read it out might be good idea here.

Copy link
Member Author

Choose a reason for hiding this comment

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

when is setState not immediate? We rely on this behaviour in quite a few places in the app...

Copy link
Contributor

Choose a reason for hiding this comment

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

From https://reactjs.org/docs/react-component.html#setstate:

Think of setState() as a request rather than an immediate command to update the component. For better perceived performance, React may delay it, and then update several components in a single pass. React does not guarantee that the state changes are applied immediately.

AFAICT, we use the (second) callback argument of setState often to be sure the state is set. No need for this here though, as you could keep the data in a local variable to query it independently.

Copy link
Member Author

Choose a reason for hiding this comment

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

fair, I wonder how much of our app would break when/if they change that assumption of ours...

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know of any places off the top of your head where we assume this.state to be updated immediately? We should probably fix that.

Copy link
Member Author

@turt2live turt2live Jul 15, 2019

Choose a reason for hiding this comment

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

I don't remember exact locations, but I believe places in MatrixChat and various atuh components at the least.

When we rewrite it in Rust we'll get 'em.

@turt2live turt2live requested a review from bwindels July 15, 2019 16:51
@turt2live turt2live merged commit 2471f92 into develop Jul 15, 2019
@turt2live turt2live deleted the travis/check-when-dead branch July 15, 2019 20:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If your HS is not available you can get two error message on the login screen
2 participants