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 server heartbeat timeout logic #8546

Merged
merged 7 commits into from
Aug 1, 2024

Conversation

arcivanov
Copy link
Contributor

Make sure to unblock the receive operation by feeding the receiver an error in a WSMessage

Change TimeoutError to ServerTimeoutError to accurately represent failure (this is backwards compatible since ServerTimeoutError has TimeoutError in the MRO)

fixes #8540

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
  • Add a new news fragment into the CHANGES/ folder

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Jul 29, 2024
Copy link

codecov bot commented Jul 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.70%. Comparing base (82d250f) to head (7f8ef98).
Report is 867 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8546      +/-   ##
==========================================
+ Coverage   97.68%   97.70%   +0.01%     
==========================================
  Files         107      107              
  Lines       33403    33425      +22     
  Branches     3923     3926       +3     
==========================================
+ Hits        32631    32659      +28     
+ Misses        559      555       -4     
+ Partials      213      211       -2     
Flag Coverage Δ
CI-GHA 97.61% <100.00%> (+0.01%) ⬆️
OS-Linux 97.27% <100.00%> (+0.01%) ⬆️
OS-Windows 95.64% <100.00%> (+<0.01%) ⬆️
OS-macOS 96.94% <100.00%> (+0.02%) ⬆️
Py-3.10.11 97.07% <100.00%> (+0.01%) ⬆️
Py-3.10.14 97.02% <100.00%> (+0.01%) ⬆️
Py-3.11.9 97.25% <100.00%> (+0.01%) ⬆️
Py-3.12.4 97.38% <100.00%> (+0.01%) ⬆️
Py-3.8.10 95.40% <100.00%> (+<0.01%) ⬆️
Py-3.8.18 96.91% <100.00%> (+0.01%) ⬆️
Py-3.9.13 97.07% <100.00%> (+0.01%) ⬆️
Py-3.9.19 97.02% <100.00%> (+0.01%) ⬆️
Py-pypy7.3.16 96.59% <100.00%> (+0.02%) ⬆️
VM-macos 96.94% <100.00%> (+0.02%) ⬆️
VM-ubuntu 97.27% <100.00%> (+0.01%) ⬆️
VM-windows 95.64% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arcivanov arcivanov force-pushed the issue_8540_master branch 2 times, most recently from b18726a to 265e01d Compare July 29, 2024 19:47
Make sure to unblock the `receive` operation by feeding the receiver an error in a `WSMessage`

Change `TimeoutError` to `ServerTimeoutError` to accurately represent failure (this is backwards compatible since `ServerTimeoutError` has `TimeoutError` in the MRO)

fixes aio-libs#8540
CHANGES/8540.bugfix.rst Outdated Show resolved Hide resolved
CHANGES/8540.bugfix.rst Outdated Show resolved Hide resolved
@bdraco bdraco added this to the 3.10.1 milestone Jul 31, 2024
CHANGES/8540.bugfix.rst Outdated Show resolved Hide resolved
CHANGES/8540.bugfix.rst Outdated Show resolved Hide resolved
@bdraco
Copy link
Member

bdraco commented Jul 31, 2024

@bdraco bdraco changed the title WSS: Fix heartbeat timeout logic Fix WebSocket server heartbeat timeout logic Jul 31, 2024
@bdraco
Copy link
Member

bdraco commented Aug 1, 2024

I want to do some more manual testing with this before merging

@bdraco
Copy link
Member

bdraco commented Aug 1, 2024

testing seems ok

Copy link
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

Thanks @arcivanov

@bdraco bdraco merged commit 4140b0e into aio-libs:master Aug 1, 2024
37 of 38 checks passed
Copy link
Contributor

patchback bot commented Aug 1, 2024

Backport to 3.10: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 4140b0e on top of patchback/backports/3.10/4140b0eda3658a3f6bd5a9479553aae4a0c14bb8/pr-8546

Backporting merged PR #8546 into master

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/aio-libs/aiohttp.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.10/4140b0eda3658a3f6bd5a9479553aae4a0c14bb8/pr-8546 upstream/3.10
  4. Now, cherry-pick PR Fix WebSocket server heartbeat timeout logic #8546 contents into that branch:
    $ git cherry-pick -x 4140b0eda3658a3f6bd5a9479553aae4a0c14bb8
    If it'll yell at you with something like fatal: Commit 4140b0eda3658a3f6bd5a9479553aae4a0c14bb8 is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x 4140b0eda3658a3f6bd5a9479553aae4a0c14bb8
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Fix WebSocket server heartbeat timeout logic #8546 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.10/4140b0eda3658a3f6bd5a9479553aae4a0c14bb8/pr-8546
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

bdraco pushed a commit that referenced this pull request Aug 1, 2024
Co-authored-by: J. Nick Koston <nick@koston.org>
(cherry picked from commit 4140b0e)
@bdraco bdraco added the backport-3.11 Trigger automatic backporting to the 3.11 release branch by Patchback robot label Aug 1, 2024
Copy link
Contributor

patchback bot commented Aug 1, 2024

Backport to 3.11: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 4140b0e on top of patchback/backports/3.11/4140b0eda3658a3f6bd5a9479553aae4a0c14bb8/pr-8546

Backporting merged PR #8546 into master

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/aio-libs/aiohttp.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.11/4140b0eda3658a3f6bd5a9479553aae4a0c14bb8/pr-8546 upstream/3.11
  4. Now, cherry-pick PR Fix WebSocket server heartbeat timeout logic #8546 contents into that branch:
    $ git cherry-pick -x 4140b0eda3658a3f6bd5a9479553aae4a0c14bb8
    If it'll yell at you with something like fatal: Commit 4140b0eda3658a3f6bd5a9479553aae4a0c14bb8 is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x 4140b0eda3658a3f6bd5a9479553aae4a0c14bb8
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Fix WebSocket server heartbeat timeout logic #8546 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.11/4140b0eda3658a3f6bd5a9479553aae4a0c14bb8/pr-8546
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

bdraco pushed a commit that referenced this pull request Aug 1, 2024
Co-authored-by: J. Nick Koston <nick@koston.org>
(cherry picked from commit 4140b0e)
bdraco added a commit that referenced this pull request Aug 1, 2024
…eout logic (#8573)

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Arcadiy Ivanov <arcadiy@ivanov.biz>
bdraco added a commit that referenced this pull request Aug 1, 2024
…eout logic (#8546) (#8574)

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Arcadiy Ivanov <arcadiy@ivanov.biz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-3.11 Trigger automatic backporting to the 3.11 release branch by Patchback robot bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WSS: _pong_not_received works (mostly) correctly but outcome is erased by receive's except EofStream:
4 participants