-
-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug in WebSocketProtocol.asgi_receive
#1619
Fix bug in WebSocketProtocol.asgi_receive
#1619
Conversation
…erver has sent the close frame
Why? |
Because I can't make the fix in IMO it's much better, because by default FastAPI depends on the code in If there's someone that can port the fix to |
I understand the effects of fixing a bug... I'm trying to understand your statement. We have two implementations, and ideally we want to match the behavior. So when you say "I don't think we should gate the fix to wsproto", I need to understand why you said that. Is it because it cannot be done? Is it because there's some kind of blocking issue? But now the follow up message was "I can't fix", which is different than the previous statement. It's not that you don't think we should, is that you don't want/can/need to dedicate time for it. Which is fine. 🙏 |
I'll look into this, for wsproto ... if that's okay. |
I spent a lot of time on this PR trying to fix the Let's go with some notes. On the description, you mentioned that we should solve the following issues:
From what I understand, we really want Let me see if I can express myself here. On |
As a note, this PR doesn't send a disconnect event to the application - only the one from the server shutdown is sent. |
Ok. Given django/asgiref#349, and my comments above, I'll be closing this PR. Sorry for taking long here, and thanks for the PR @kylebebak . 🙏 |
Sorry for not responding to this until now @Kludex , thank you for reviewing this PR. I didn't explain this as well as I should have, and I think the client/server/application terminology was a little confusing. I still think the current uvicorn behavior isn't ideal, and the best way to summarize my concerns is the code I pasted in the first comment, that uses client/server terminology in example code in the websockets docs. If you do this, e.g. with Python 3.11...
...you'll see that the WS handler can read messages in its read queue with I believe this is more than an implementation detail, and that it's an important difference in behavior between |
@Kludex @euri10
Note: this PR obsoletes this old one, which was closed anyway
There were 2 things to fix in #1230:
The first item was fixed was fixed by this PR: #1252. But I realized after this PR was merged that the second item hadn't been fixed.
This PR fixes the second item. It ensures that the server can "drain" unread frames in the read queue even after the server has sent the close frame, as long as those frames were sent before the server sent the close frame.
As with the first item, the second item is part of the websockets spec. The following code, using just the
websockets
library, makes it clear that this is the intended behavior of this library.I did not include code in this PR that fixes this bug in
wsproto_impl.py
, because I'm not familiar withwsproto
. That said, I don't think we should gate this fix on the corresponding fix inwsproto
.client.py
server.py