Skip to content

[PR #10971/1ee187c0 backport][3.11] Fix WebSocketResponse.prepared not correctly reflect the WebSocket's prepared state #10982

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

Conversation

patchback[bot]
Copy link
Contributor

@patchback patchback bot commented May 23, 2025

This is a backport of PR #10971 as merged into master (1ee187c).

This PR fixes an issue where the WebSocketResponse.prepared property did not correctly reflect the WebSocket's prepared state, particularly during timeout scenarios.

Previously, the prepared property inherited from StreamResponse only checked for _payload_writer, but in WebSocket timeout scenarios, the _writer could be set while _payload_writer remained None, leading to incorrect state reporting.

Changes

  • Added an explicit prepared property to WebSocketResponse that checks for _writer instead of relying on the parent class's _payload_writer check
  • Added a check in the prepare() method to prevent double preparation when _writer is already set
  • Added comprehensive tests covering timeout scenarios and edge cases where WebSocket state needs to be correctly tracked

fixes #6009

@bdraco bdraco enabled auto-merge (squash) May 23, 2025 19:00
Copy link

codspeed-hq bot commented May 23, 2025

CodSpeed Performance Report

Merging #10982 will not alter performance

Comparing patchback/backports/3.11/1ee187c08c9bb59acb53e1c80a06c79a4183de10/pr-10971 (1cd0c38) with 3.11 (3d6be6e)

Summary

✅ 55 untouched benchmarks

Copy link

codecov bot commented May 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.08%. Comparing base (3d6be6e) to head (1cd0c38).
Report is 1 commits behind head on 3.11.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             3.11   #10982   +/-   ##
=======================================
  Coverage   98.08%   98.08%           
=======================================
  Files         126      126           
  Lines       37747    37811   +64     
  Branches     4568     4569    +1     
=======================================
+ Hits        37023    37087   +64     
  Misses        546      546           
  Partials      178      178           
Flag Coverage Δ
CI-GHA 97.97% <100.00%> (+<0.01%) ⬆️
OS-Linux 97.66% <100.00%> (+<0.01%) ⬆️
OS-Windows 94.65% <100.00%> (+<0.01%) ⬆️
OS-macOS 96.81% <100.00%> (+0.01%) ⬆️
Py-3.10.11 96.67% <100.00%> (+<0.01%) ⬆️
Py-3.10.17 97.18% <100.00%> (-0.05%) ⬇️
Py-3.11.12 97.25% <100.00%> (+0.01%) ⬆️
Py-3.11.9 96.75% <100.00%> (+<0.01%) ⬆️
Py-3.12.10 97.75% <100.00%> (+<0.01%) ⬆️
Py-3.13.3 97.73% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 96.58% <100.00%> (+0.01%) ⬆️
Py-3.9.22 97.09% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.16 96.65% <100.00%> (+<0.01%) ⬆️
VM-macos 96.81% <100.00%> (+0.01%) ⬆️
VM-ubuntu 97.66% <100.00%> (+<0.01%) ⬆️
VM-windows 94.65% <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.

@bdraco bdraco merged commit 39459ab into 3.11 May 23, 2025
36 checks passed
@bdraco bdraco deleted the patchback/backports/3.11/1ee187c08c9bb59acb53e1c80a06c79a4183de10/pr-10971 branch May 23, 2025 19:24
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