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

Fix websocket timer throttle blocking writes #670

Closed
wants to merge 1 commit into from

Conversation

hyperlink
Copy link

Note: the engine.io.js file is the generated output of make engine.io.js, and should not be manually modified.

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behaviour

An immediate setTimeout is used to unblock the WebSocket write. Unfortunately, this setTimeout can be throttled by browsers when the tab is backgrounded. This can lead to missed pong responses to server pings which leads to disconnects.

New behaviour

Move the unblocking code block into a then handler of an immediate Promise.resolve. The then handler does not suffer from Timer throttling and will ensure the code gets executed asynchronously without unintended delay.

Other information (e.g. related issues)

#649 (comment)

darrachequesne pushed a commit that referenced this pull request Jun 22, 2021
An immediate setTimeout was used to unblock the WebSocket write.
Unfortunately, this setTimeout can be throttled by browsers when the
tab is backgrounded.

This can lead to missed pong responses to server pings, which
eventually leads to disconnection.

Related: #649
@hyperlink
Copy link
Author

👍🏼

@hyperlink hyperlink closed this Jun 23, 2021
@hyperlink hyperlink deleted the fix-setTimeout-throttle branch June 23, 2021 01:32
This pull request was closed.
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.

1 participant