bare websockets - #6932
Conversation
Merging this PR will not alter performance
Performance Changes
Comparing Footnotes
|
Greptile SummaryThis 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; no new actionable regressions or outstanding previous findings remain. The changes since the previous review do not introduce a concrete transport failure, and every previous Greptile thread is resolved and therefore not outstanding.
|
| Filename | Overview |
|---|---|
| packages/reflex-base/src/reflex_base/.templates/web/utils/helpers/websocket.js | Implements the browser-side plain-WebSocket transport, including framing, heartbeat handling, buffering, and lifecycle cleanup. |
| packages/reflex-base/src/reflex_base/.templates/web/utils/state.js | Selects the configured transport, lazily imports Socket.IO, and safely manages asynchronous connection and unmount cleanup. |
| reflex/event_namespace.py | Implements the server-side plain-WebSocket event protocol and its connection, validation, logging, and token-management behavior. |
| reflex/socketio_namespace.py | Extracts the legacy Socket.IO namespace and ASGI integration behind the optional Socket.IO dependency. |
| reflex/app.py | Configures either the native WebSocket route or optional Socket.IO application according to transport settings. |
| reflex/testing.py | Migrates the test harness backend to Granian and reports a clear optional-dependency error when cleanup lacks psutil. |
| packages/reflex-base/src/reflex_base/event/processor/event_processor.py | Forks the root event context for streaming deltas so unrelated events cannot become children of a completed future. |
| pyproject.toml | Moves Socket.IO and Uvicorn stacks into explicit extras while updating the required Granian version. |
| tests/units/test_event_namespace.py | Adds broad coverage for WebSocket framing, connection validation, event dispatch, rate limiting, and lifecycle behavior. |
Reviews (32): Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." | 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 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. |
masenf
left a comment
There was a problem hiding this comment.
reflex-xy currently uses socketio multiplexing to send binary chart data and interaction payloads over the same reflex websocket, so we can't bring this in directly, yet.
i think there's potential here though. and i like the idea of dependency reduction.
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