WebSocketResponse.close() should wait for a close frame in its timeout window #9506
Description
Describe the bug
After calling WebSocketResponse.close() the server waits for a single message from the client, and if it's not a close message, then it indicates an abnormal closure:
Lines 489 to 506 in 13dc020
The problem with this is that a non-close client message might be in flight when the server sends its close message, and this results in an abnormal closure at the server's side, even if the client responds to the close message immediately. Here is the situation I'm describing:
To my best understanding this is reported as an abnormal closure on the server side based on the implementation of WebSocketResponse.close().
To Reproduce
I didn't write a reproducer yet.
Expected behavior
During the timeout wait for a close message, and discard messages that arrive before that. Only report an abnormal closure if that close message never arrives.
Logs/tracebacks
NAPython Version
allaiohttp Version
master, as of writing 13dc0200d855bdfec1d4c4f3e1c9a1c66f88f1ebmultidict Version
NApropcache Version
NAyarl Version
NAOS
NA
Related component
Server
Additional context
No response
Code of Conduct
- I agree to follow the aio-libs Code of Conduct