-
Notifications
You must be signed in to change notification settings - Fork 4k
[WIP] Add optional support for running Streamlit with Starlette #12772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ PR preview is ready!
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request introduces optional support for running Streamlit with Starlette instead of Tornado as the server framework. The prototype adds a new configuration flag server.useStarlette that allows switching between the existing Tornado implementation and a new Starlette/ASGI-based server.
- Adds Starlette as an optional dependency with required supporting libraries (uvicorn, python-multipart, anyio)
- Implements a complete Starlette application with HTTP endpoints, WebSocket handling, and authentication routes
- Provides comprehensive migration documentation outlining the technical approach and implementation plan
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tornado-starlette-migration.md | Detailed migration documentation covering scope, risks, implementation plan, and technical mapping from Tornado to Starlette |
| lib/streamlit/config.py | Adds server.useStarlette configuration option to enable experimental Starlette server |
| lib/streamlit/web/server/server.py | Modifies server startup to conditionally use Starlette implementation based on config flag |
| lib/streamlit/web/server/starlette_app.py | Core Starlette application implementation with all HTTP endpoints and WebSocket handling |
| lib/streamlit/web/server/starlette_auth_routes.py | Authentication routes implementation for Starlette using authlib integration |
| lib/setup.py | Adds optional "starlette" dependency group with required packages |
| lib/test-requirements.txt | Adds Starlette-related testing dependencies |
| lib/tests/streamlit/web/server/starlette_*.py | Comprehensive test coverage for Starlette implementation |
| lib/tests/streamlit/web/server/server_test.py | Updates existing server tests to cover both Tornado and Starlette implementations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
@cursor review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.
SummaryThis PR adds optional support for running Streamlit with Starlette/Uvicorn as an alternative to the existing Tornado server implementation. The new server is controlled by a new config option
This addresses many long-standing community requests for ASGI support, better async performance, and FastAPI integration capabilities. Code QualityThe code is well-structured with clear separation of concerns and follows the project's coding conventions. Key observations: Strengths
Issues to Address
Test CoverageThe test coverage is excellent with comprehensive unit tests for all new modules:
Test Quality Assessment
Gaps Identified
Backwards Compatibility
The feature is opt-in, so existing users are unaffected unless they enable Security & RiskSecurity Assessment ✅
Risk Assessment
Recommendations
VerdictCHANGES REQUESTED: The implementation is high-quality and well-tested, but running E2E tests exclusively with Starlette creates a significant risk of silent regressions in the Tornado backend, which remains the default. This should be addressed before merge by either running E2E tests for both backends or explicitly acknowledging Tornado E2E coverage is being dropped. This is an automated AI review. Please verify the feedback and use your judgment. |
SummaryThis PR introduces an experimental Starlette-based server implementation ( Code QualityThe code is well-structured and modular.
Test Coverage
Backwards Compatibility
Security & Risk
Recommendations
VerdictAPPROVED: The changes are high quality, well-tested, and introduce a significant architectural improvement behind a feature flag. |
SummaryThis PR adds an experimental Starlette + Uvicorn server implementation behind the new config flag Key touchpoints include:
Code Quality
Test Coverage
Backwards Compatibility
Security & Risk
In Tornado, the browser websocket handler checks origins via
In Starlette, the WebSocket endpoint accepts connections without any Origin validation:
This is a security regression: without an Expected fix: implement an Origin validation step for websockets mirroring Tornado’s behavior (likely using
Even if Starlette defaults are reasonable, for parity and clarity it would be safer to explicitly set:
This is a large surface area change and can introduce regressions/flakes unrelated to the actual PR goals. Recommendations
VerdictCHANGES REQUESTED: The Starlette websocket endpoint currently lacks Origin allowlisting (security regression vs Tornado) and the PR forces Starlette for all Playwright e2e tests, reducing coverage of the default Tornado path. This is an automated AI review. Please verify the feedback and use your judgment. |
|
Closing this since the feature was merged in via other PRs. This will be released as experimental in 1.53. |
Describe your changes
Implements the option to run Streamlit via starlette+uvicorn as an alternative to tornado via
--server.useStarlett.GitHub Issue Link (if applicable)
get_tornado_instanceas an experimental API #8661Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.