Skip to content

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

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

Copy link

codecov bot commented May 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.16%. Comparing base (bfe0bd1) to head (c283fcb).
Report is 1 commits behind head on 3.12.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             3.12   #10983      +/-   ##
==========================================
+ Coverage   97.88%   98.16%   +0.28%     
==========================================
  Files         130      130              
  Lines       39755    39819      +64     
  Branches     2241     2241              
==========================================
+ Hits        38914    39090     +176     
+ Misses        659      557     -102     
+ Partials      182      172      -10     
Flag Coverage Δ
CI-GHA 98.05% <100.00%> (+0.26%) ⬆️
OS-Linux 97.78% <100.00%> (+0.01%) ⬆️
OS-Windows 95.27% <100.00%> (?)
OS-macOS 96.95% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 96.84% <100.00%> (+0.27%) ⬆️
Py-3.10.17 97.38% <100.00%> (+0.01%) ⬆️
Py-3.11.12 97.48% <100.00%> (+0.66%) ⬆️
Py-3.11.9 96.93% <100.00%> (+0.27%) ⬆️
Py-3.12.10 97.83% <100.00%> (+0.25%) ⬆️
Py-3.13.3 97.83% <100.00%> (+0.87%) ⬆️
Py-3.9.13 96.73% <100.00%> (+0.27%) ⬆️
Py-3.9.22 97.25% <100.00%> (+0.61%) ⬆️
Py-pypy7.3.16 85.78% <100.00%> (?)
VM-macos 96.95% <100.00%> (+<0.01%) ⬆️
VM-ubuntu 97.78% <100.00%> (+0.01%) ⬆️
VM-windows 95.27% <100.00%> (?)

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 enabled auto-merge (squash) May 23, 2025 19:00
Copy link

codspeed-hq bot commented May 23, 2025

CodSpeed Performance Report

Merging #10983 will not alter performance

Comparing patchback/backports/3.12/1ee187c08c9bb59acb53e1c80a06c79a4183de10/pr-10971 (c283fcb) with 3.12 (bfe0bd1)

Summary

✅ 59 untouched benchmarks

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