Skip to content

Conversation

@blast-hardcheese
Copy link
Contributor

Why

When we hit the maximum size of a websocket packet the websocket client proactively disconnects itself. Unfortunately this can happen outside of the observed lifecycle of the owned socket, so when we attempt to reconnect we just resend the last request and see whether or not we get a valid response.

What changed

  • Disable max_size during websocket.connect(...)

Test plan

CI

Without the bugfix commit, test logs include:

DEBUG    replit_river.common_session:common_session.py:102 _buffered_message_sender: Sent 'jKAcLL2O3XBL4xZF1cEWv'
DEBUG    websockets.server:protocol.py:572 < BINARY 8b a2 69 64 b5 6a 4b 41 63 4c 4c 32 4f 33 58 42 ... 70 61 79 6c 6f 61 64 80 [244 bytes]
DEBUG    websockets.server:protocol.py:719 > BINARY 88 a2 69 64 b5 52 42 59 4b 6a 42 2d 63 59 37 5f ... 61 61 61 61 61 61 61 61 [1048711 bytes]
DEBUG    websockets.client:protocol.py:719 > CLOSE 1009 (message too big) over size limit (? > 1048576 bytes) [37 bytes]
DEBUG    websockets.client:protocol.py:169 = connection is CLOSING
DEBUG    websockets.server:protocol.py:572 < CLOSE 1009 (message too big) over size limit (? > 1048576 bytes) [37 bytes]
DEBUG    websockets.server:protocol.py:719 > CLOSE 1009 (message too big) over size limit (? > 1048576 bytes) [37 bytes]
DEBUG    websockets.server:protocol.py:169 = connection is CLOSING
DEBUG    websockets.server:protocol.py:731 > EOF
DEBUG    websockets.server:connection.py:890 x half-closing TCP connection

but now we're able to negotiate the full response and subsequently close gracefully.

@blast-hardcheese blast-hardcheese force-pushed the dstewart/session-lifecycle-bugfixes branch from 35f5e71 to 8f2e4a8 Compare May 6, 2025 19:29
@blast-hardcheese blast-hardcheese requested a review from a team as a code owner May 6, 2025 19:29
@blast-hardcheese blast-hardcheese requested review from jackyzha0 and removed request for a team May 6, 2025 19:29
@blast-hardcheese blast-hardcheese enabled auto-merge (squash) May 6, 2025 23:03
Copy link
Member

@jackyzha0 jackyzha0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to me that we should just kill the session in this case? its weird that we break the connection on max size exceeded but allow it on reconnect

Copy link
Member

@jackyzha0 jackyzha0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops misread, thought .connect(max_size=None) only applied to first message

@blast-hardcheese blast-hardcheese force-pushed the dstewart/session-lifecycle-bugfixes branch from 8f2e4a8 to eb9088a Compare May 7, 2025 02:44
@blast-hardcheese blast-hardcheese merged commit fb8d312 into main May 7, 2025
4 checks passed
@blast-hardcheese blast-hardcheese deleted the dstewart/session-lifecycle-bugfixes branch May 7, 2025 02:46
@blast-hardcheese blast-hardcheese added the bug Something isn't working label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants