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

Increase initial WS timeout to try to mitigate slow connection problem #1684

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

MetRonnie
Copy link
Member

@MetRonnie MetRonnie commented Feb 21, 2024

subscriptions-transport-ws uses an exponential backoff function to cancel and retry the WebSocket connection when it first connects. The default initial timeout is 1s - https://github.com/apollographql/subscriptions-transport-ws/blob/master/src/defaults.ts#L1

I've increased it to 3s here to try and mitigate the slow initial connection problem #1200, though according to Oliver that problem may be caused by the connection closing unexpectedly (which triggers the WebSocket's onclose) rather than timing out (which doesn't). It's worth a shot anyway.

Check List

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • CHANGES.md entry not included as we don't know if this fixes the problem

@MetRonnie MetRonnie added this to the 2.4.0 milestone Feb 21, 2024
@MetRonnie MetRonnie self-assigned this Feb 21, 2024
@MetRonnie MetRonnie marked this pull request as ready for review February 22, 2024 09:32
@oliver-sanders
Copy link
Member

I have reproduced the issue in #1200 with a similar diff (see #1200 (comment)), so I don't think this is a solution to that problem.

However, this may be a solution to an asymptomatic issue which you can sometimes see evidence of in the console where the first couple of connection attempts fail. This could be because the server is unable to send a response within the 1s window forcing timeout and reconnect.

@oliver-sanders
Copy link
Member

Tested this branch against master looking for evidence in the console of failed connection events. These show up like so:

Screenshot from 2024-02-26 16-35-42

I couldn't replicate #1200 on either branch after 10 tries. On master I save failures 2/10 times, on this branch 0/10 times.

@oliver-sanders oliver-sanders merged commit 1356359 into cylc:master Feb 26, 2024
5 of 6 checks passed
@MetRonnie MetRonnie deleted the ws-timeout branch February 26, 2024 16:47
@kinow
Copy link
Member

kinow commented Mar 30, 2024

Ah, you kept the logs of when that happened, @oliver-sanders 👆

I couldn't find any old screenshots from when this issue happened, but I remember there was something in the JS console. Your screenshot above might confirm a suspicious I had about this bug. GOing to comment in the main issue, linking to this one.

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.

3 participants