fix(websocket): bound slow-consumer output buffers - #225
Open
loks0n wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clients that stop reading can make Swoole retain enough outgoing data across connections to exhaust a realtime container. Port utopia-php/websocket#31 into the monorepo: default each connection's output buffer to 512KB, apply the limit to the listen port before startup, disable
send_yieldwhen capped, and disconnect clients when a push fails so message loss is not silent.The constructor accepts
socketBufferSize; passing0retains Swoole's default buffer size and yield behavior. Failed pushes still disconnect clients. The new default changes behavior for clients that fall behind, so this needs to be accounted for when choosing the release version.Adds README guidance and an end-to-end regression that stops reading from one client, fills its outgoing buffer, and verifies that it is disconnected while another client still exchanges messages. This test fails both with the cap removed and with disconnect-on-failure removed.
Validation:
bin/monorepo check websocket— Pint, PHPStan, and Rector pass.bin/monorepo test websocket— 9 unit tests and 3 end-to-end tests pass with real Swoole and Workerman servers.bin/monorepo validate, Vale for the package README, andgit diff --checkpass.