Merged
Conversation
CodSpeed Performance ReportMerging #5955 will not alter performanceComparing Summary
|
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
This PR adds configurable polling transport support as an alternative to WebSocket connections. The implementation allows users to set transport: "polling" or transport: "websocket" in their config, and this value flows through to both the backend Socket.IO server and frontend client.
Key Changes:
- Added
transportconfig field with Literal typing ("websocket"|"polling") - Modified Socket.IO server initialization to use
config.transportinstead of hardcoded["websocket"] - Updated frontend to read transport from
env.TRANSPORTinstead of hardcoded value - Added
TRANSPORTkey to env.json generation
Critical Issues:
- CORS Configuration Regression: The PR hardcodes
cors_allowed_origins=[]andcors_credentials=False, completely ignoring user'sconfig.cors_allowed_originssetting. This breaks existing apps with custom CORS requirements. Socket.IO polling requires CORS configuration for the initial HTTP handshake. - Transport Upgrade Blocked:
allow_upgrades=Falseprevents automatic upgrade from polling to WebSocket, which may not be the desired behavior for all use cases.
Confidence Score: 1/5
- This PR has critical regressions that will break existing production apps with custom CORS configurations
- The hardcoded CORS configuration (
cors_allowed_origins=[],cors_credentials=False) removes support for user-configured CORS settings that were previously respected. This is a breaking change that will prevent WebSocket/polling connections in production environments where CORS is properly configured. The feature implementation itself is sound, but the CORS regression must be fixed before merging. - Pay critical attention to
reflex/app.py- the CORS configuration must be restored to respectconfig.cors_allowed_origins
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| reflex/app.py | 1/5 | Critical CORS configuration regression - hardcoded empty array breaks user config; allow_upgrades=False may prevent websocket upgrade |
| reflex/config.py | 5/5 | Added transport config option with proper Literal typing - clean implementation |
| reflex/utils/build.py | 4/5 | Added TRANSPORT to env.json - minor style issue with hardcoded string literal |
| reflex/.templates/web/utils/state.js | 5/5 | Changed from hardcoded "websocket" to dynamic env.TRANSPORT - correct implementation |
Sequence Diagram
sequenceDiagram
participant User as User Config
participant Build as build.py
participant EnvJSON as env.json
participant Frontend as state.js
participant App as app.py
participant SocketIO as Socket.IO Server
User->>App: Set transport config
Note over User,App: Config: transport = "websocket" | "polling"
Build->>User: Read config.transport
Build->>EnvJSON: Write TRANSPORT value
Note over EnvJSON: env.json contains TRANSPORT key
Frontend->>EnvJSON: Read env.TRANSPORT
Frontend->>SocketIO: Connect with [env.TRANSPORT]
Note over Frontend,SocketIO: Previously hardcoded ["websocket"]
App->>SocketIO: Initialize AsyncServer
Note over App,SocketIO: transports=[config.transport]<br/>allow_upgrades=False<br/>CORS hardcoded to []
alt Websocket Transport
SocketIO-->>Frontend: WebSocket connection
else Polling Transport
SocketIO-->>Frontend: HTTP long-polling
Note over SocketIO,Frontend: Cannot upgrade to WebSocket
end
4 files reviewed, 3 comments
masenf
approved these changes
Nov 6, 2025
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.
No description provided.