Conversation
18e1733 to
3a76249
Compare
3a76249 to
8c41e27
Compare
Merging this PR will degrade performance by 16.27%
Performance Changes
Comparing Footnotes
|
8c41e27 to
2535de8
Compare
src/workerd/api/web-socket.c++
Outdated
| // fires for a server-initiated close. Queue a proper close reply frame through the | ||
| // outgoing message pump so that a reciprocal Close frame is actually sent on the | ||
| // wire, then mark outgoing as closed. | ||
| auto pendingAutoResponses = autoResponseStatus.pendingAutoResponseDeque.size() - |
There was a problem hiding this comment.
This seems like the wrong layer to solve this
|
We intentionally don't send close messages automatically in reply to receiving a close because it breaks proxying. Imagine a worker which has two WebSocket connections open, A and B, and is proxying between them (forwarding all messages received on A to B and vice versa). Now the worker receives a close message on A. It forwards the close message to B. It then needs to wait for B's reply close message, so it can then forward that to A. If the system automatically sends a close reply to A immediately upon receiving a close message, this doesn't work right. This is why we didn't implement it that way. With that said, you could make some valid arguments that we made the wrong choice here. Is it actually important that B get a chance to flush remaining messages and provide its own close message? Given that the WebSocket spec says that the reply close should happen automatically, perhaps it's the case that WebSocket close messages are not intended to be graceful, but rather intended to immediately terminate the connection. This isn't really "good networking theory" but maybe it's fine in practice and not worth it to deviate? Maybe what we should really do is provide an explicit extension that lets people specify when they want to manually manage close messages? Like an I could be convinced. |
7ee846c to
f5ce26a
Compare
For web compliance... purposes...