Skip to content

Accept ReadError from a read pending during ASGI WebSocket close - #1354

Merged
Kludex merged 2 commits into
mainfrom
accept-read-error-on-pending-ws-read
Nov 17, 2026
Merged

Kludex merged 2 commits into
mainfrom
accept-read-error-on-pending-ws-read

Conversation

@Kludex

@Kludex Kludex commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

test_read_during_and_after_close fails on anyio 4.16.0, as reported in #1309.

Since anyio 4.16.0, closing a memory stream wakes a pending receive() with ClosedResourceError instead of EndOfStream. A read that is pending when aclose() runs now raises httpcore2.ReadError instead of returning b"".

Both outcomes are valid, so only the test changes:

  • AsyncWebSocketSession handles ReadError and EOF in the same except clause.
  • The httpcore2 anyio backend also raises ReadError when a read is interrupted by a local close.

The test now accepts either outcome for the pending read. It still requires ReadError for a read started after close.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

Session: pi --session 01a1e9c9-f8a7-747b-8fb8-baaed8bd78de

View guided diff

@veria-ai

veria-ai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T14:06:28.236200Z c007f60 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

View guided diff | Re-trigger cubic

@codspeed

codspeed Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing accept-read-error-on-pending-ws-read (c210bda) with main (674d4cb)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@Kludex
Kludex merged commit cabbaca into main Nov 17, 2026
19 checks passed
@Kludex
Kludex deleted the accept-read-error-on-pending-ws-read branch November 17, 2026 15:20
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