[serve] Clean up leaked receive task when request times out in direct ingress mode#64123
[serve] Clean up leaked receive task when request times out in direct ingress mode#64123akyang-anyscale wants to merge 2 commits into
Conversation
Signed-off-by: akyang-anyscale <alexyang@anyscale.com>
There was a problem hiding this comment.
Code Review
This pull request ensures that the receive_task is properly cancelled alongside the request_task when an ASGI call times out, preventing task leaks. It also introduces a helper method to track in-flight direct-ingress tasks and adds a corresponding integration test to verify the cleanup behavior. The review feedback suggests two improvements: simplifying the coroutine name retrieval in the helper method by using the standard __name__ attribute instead of CPython internals, and simplifying the test headers by using standard strings instead of byte-encoded keys and values.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Before, the receive task would be left on the queue because it was never canceled in the request timeout path. This PR fixes that and adds a test for it.