Skip 500 after completed POST response on closed writer
Closed
DH
1mo ago+53+53+01234567890123456789-7-7-0123456789
Fixes #3651
Notification POSTs send 202 Accepted before forwarding to the session writer. If the writer is closed, the resulting ClosedResourceError was answered with a second response (500), which Uvicorn rejects with RuntimeError: Unexpected ASGI message after completed. Track whether the POST response was already sent and, if so, log and drop instead of sending another response; also tolerate a closed writer when forwarding the error.
Assisted by AI (Muse Spark) with human review and verification — repro reviewed and run locally.
Test plan:
- New regression test
test_closed_writer_notification_post_sends_single_202passes; fails without the fix with RuntimeError - pytest on streamable-HTTP suites: 206 passed
- ruff check, ruff format --check, pyright clean on touched files