websocket: honor context cancellation in input reads - #490
Conversation
|
Commits Review
The choice to return an already-parsed message even when LGTM |
Refactor `ReadBatch` to handle context cancellations properly, ensuring idle connections or cancellation during reads do not block graceful shutdown. Add comprehensive tests for input read behavior under various context cancellation scenarios. Note for reviewers on `TestWebsocketReadBatchCancelKeepsMessage`: - **Deterministic setup:** Packs two WebSocket frames into a single TCP write to ensure the second frame is buffered in userspace before cancellation. - **Unit contract:** Asserts `websocketReader.ReadBatch` returns already-buffered messages rather than dropping them on `ctx.Err()`. - **Scope limitation:** Tests the reader in isolation; end-to-end message preservation across the pipeline during shutdown remains subject to `AsyncReader` lifecycle handling.
d4e8a6a to
bd0806c
Compare
|
Commits Review Test coverage is solid: LGTM |
Refactor
ReadBatchto handle context cancellations properly, ensuring idle connections or cancellation during reads do not block graceful shutdown.Add comprehensive tests for input read behavior under various context cancellation scenarios.
Note for reviewers on
TestWebsocketReadBatchCancelKeepsMessage:websocketReader.ReadBatchreturns already-buffered messages rather than dropping them onctx.Err().AsyncReaderlifecycle handling.Refs: