Skip to content

Clear pending disconnected timer before scheduling another - #4464

Open
lukaszsamson wants to merge 1 commit into
phoenixframework:mainfrom
lukaszsamson:ls-clear-delayed-timeout
Open

lukaszsamson wants to merge 1 commit into
phoenixframework:mainfrom
lukaszsamson:ls-clear-delayed-timeout

Conversation

@lukaszsamson

Copy link
Copy Markdown
Contributor

Before this PR stale timer can stack and firee phx-disconnected after reconnect resulting in "offline" banner that never clears

Comment on lines +1456 to 1459
this.disconnectedTimer != null && clearTimeout(this.disconnectedTimer);
this.disconnectedTimer = setTimeout(() => {
this.execAll(this.binding("disconnected"));
}, this.liveSocket.disconnectedTimeout);

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.

That will delay showing an error, while it might be better to early exit if there's already one scheduled, since hideLoader already cancels.

Suggested change
this.disconnectedTimer != null && clearTimeout(this.disconnectedTimer);
this.disconnectedTimer = setTimeout(() => {
this.execAll(this.binding("disconnected"));
}, this.liveSocket.disconnectedTimeout);
if (this.disconnectedTimer != null) { return };
this.disconnectedTimer = setTimeout(() => {
this.disconnectedTimer = null;
this.execAll(this.binding("disconnected"));
}, this.liveSocket.disconnectedTimeout);

Wdyt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants