Repository navigation
fix(websocket): derive the inflate limit from the retained decompressed data - #17
Merged
Merged
Conversation
terry-xiaoyu
force-pushed
the
261009-ws-deflate-budget
branch
from
October 9, 2026 10:01
b1dabbe to
0cabc74
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The upstream fix is consistently applied and covered across both WebSocket implementations.
0 open findings
What changed in this PR
Ports the upstream WebSocket inflate-budget fix to both WebSocket implementations.
Changes:
- Derives remaining inflate capacity from retained decompressed payload.
- Adds segmented, masked, fragmented, boundary, and unlimited-size tests.
- Adds
meckfor deterministic inflate barriers.
| File | Description |
|---|---|
src/cowboy_websocket.erl |
Corrects inflate-limit accounting. |
src/cowboy_websocket_linger.erl |
Mirrors the accounting fix. |
test/ws_SUITE.erl |
Adds comprehensive regression coverage. |
test/ws_SUITE_data/ws_max_frame_size_deflate.erl |
Provides the limit-aware echo handler. |
Makefile |
Adds the meck test dependency. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ed data The remaining inflation budget now comes from the decompressed payload retained for the current message. The masking offset continues to use the wire byte counter. The ps_payload field holding the decompressed payload is renamed to payload; field count and order are unchanged. The tests cover compressed messages delivered in several TCP segments: over the limit, exactly at the limit, a non-zero masking key, fragmented messages and max_frame_size = infinity. Responses are read by frame length, so a frame split over several receives is handled.
terry-xiaoyu
force-pushed
the
261009-ws-deflate-budget
branch
from
October 9, 2026 20:04
0cabc74 to
c26e97f
Compare
ieQu1
approved these changes
Oct 11, 2026
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.
Ports the upstream accounting fix (ninenines/cowboy
09d0a24b14) to the 2.13 line EMQX pins, and applies it to thecowboy_websocket_lingermodule this fork adds.What changed
ps_payloadfield holding the decompressed payload is renamed topayload. Field count and order are unchanged, so a suspended connection can carry its parse state across a code upgrade.Tests
test/ws_SUITE.erlgains a serial group per websocket module covering compressed messages delivered in several TCP segments: over the limit, exactly at the limit, with a non-zero masking key, fragmented messages, andmax_frame_size = infinity. Segment delivery is made deterministic by waiting for the connection's inflate result, responses are read by frame length, andmeckis added as a test dependency for the barrier.Local runs on OTP 27:
ws_SUITE110/110 andws_handler_SUITE106/106.Upstream
The same accounting fix is in upstream master as
09d0a24b14. This branch keeps the 2.13 structure: a separatecowboy_websocket_lingermodule andinfinityas the default limit.