bare websockets - #6932
Conversation
Merging this PR will not alter performance
Performance Changes
Comparing Footnotes
|
Greptile SummaryThe PR replaces the default Socket.IO transport with a lightweight plain-WebSocket protocol while retaining Socket.IO as an optional transport.
Confidence Score: 5/5The PR appears safe to merge because the previously reported transport issues are fixed or explicitly accepted and no blocking failure remains. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| reflex/event_namespace.py | Implements the plain-WebSocket backend protocol and now closes malformed or undeserializable client frames while correctly enforcing the configured UTF-8 byte limit. |
| packages/reflex-base/src/reflex_base/.templates/web/utils/helpers/websocket.js | Adds the browser WebSocket transport, including handshake, heartbeat watchdog, reconnect-compatible callbacks, buffering, and documented timeout durations. |
| packages/reflex-base/src/reflex_base/.templates/web/utils/state.js | Selects the plain or optional Socket.IO client transport and coordinates connection setup, reconnection, and unmount cleanup. |
| reflex/app.py | Registers the selected event transport and integrates the plain-WebSocket route into the application runtime. |
| reflex/utils/exec.py | Updates backend launch paths and Uvicorn WebSocket limits for the transport configuration. |
| reflex/testing.py | Migrates AppHarness backend serving to Granian and adjusts test-server lifecycle management. |
| pyproject.toml | Moves transport-specific server and Socket.IO dependencies into optional extras. |
| tests/units/test_event_namespace.py | Covers connection handling, malformed-frame closure, invalid events, UTF-8 size boundaries, heartbeat behavior, and transport error handling. |
Reviews (27): Last reviewed commit: "Merge branch 'main' into make-sio-option..." | Re-trigger Greptile
There was a problem hiding this comment.
All reported issues were addressed across 19 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…ace, awaited disconnect cleanup; revert server-wide ws_max_size
There was a problem hiding this comment.
All reported issues were addressed across 17 files
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
… message shape, log protocol closes; add transport benchmarks
…cut client watchdog churn
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
…icorn] extra with gunicorn
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 1 file (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
…ayer via ws_max_size make greptile happy
|
I really like this lightweight approach 👍 . |
Thanks 🙏 Yes, the new bare websockets implementation does not support http long-polling yet. However one could still choose the old socketio based transport to archive this. Also iirc longpolling was disabled by default anyway, i guess not a lot of users use it. If this is really needed i could add support to our bare websockets implementation as well. |
saves ~11.6 KB gz / ~41 KB raw frontend size (a small js chunk replaces whole socketio)
dropped python deps: wsproto, simple-websocket, python-socketio, python-engineio, bidict
new benchmarks in test_event_transport.py show about 2x performance increase compared to socketio
also migrates AppHarness to granian for consistency. otherwise downstream tests using AppHarness still need uvicorn and wsproto/websockets