Skip to content

[fix] Allow websockets 17.x - #17113

Merged
sfc-gh-lwilby-1 merged 1 commit into
developfrom
chore/raise-websockets-upper-bound
Sep 25, 2026
Merged

sfc-gh-lwilby-1 merged 1 commit into
developfrom
chore/raise-websockets-upper-bound

Conversation

@sfc-gh-lwilby-1

Copy link
Copy Markdown
Contributor

Describe your changes

Raises the published websockets cap from <17 to <18 so Streamlit can install alongside websockets 17.x.

The <17 bound was the unused next-major policy cap from #15948, not a known incompatibility. Websockets 17 dropped Python 3.10, so 3.10 installs stay on 16.1.x (same pattern as pandas 3). The workspace lock pins 17.x on Python 3.11+ so CI actually exercises the new major.

Python 3.10 + websockets>=17 remains impossible because 17.x itself requires Python >= 3.11.

GitHub Issue Link (if applicable)

Testing Plan

  • No new test files: this is a dependency-range change. Existing Starlette server/websocket, logger, and FIPS smoke tests passed locally against websockets 17.1 on Python 3.13.
  • Min-version CI still installs websockets==12.0.0. Python 3.10 CI stays on 16.1.x; 3.11+ CI uses 17.1.
  • Unit Tests (JS and/or Python)
  • Python unit tests (existing server/websocket/FIPS suite)

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

Made with Cursor

@sfc-gh-lwilby-1 sfc-gh-lwilby-1 added change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Sep 24, 2026
@snyk-io

snyk-io Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

@sfc-gh-lwilby-1 sfc-gh-lwilby-1 added the ai-qa-test If applied to PR, an AI qa testing will run on the feature implemented in the PR. label Sep 24, 2026
@sfc-gh-lwilby-1
sfc-gh-lwilby-1 marked this pull request as ready for review September 24, 2026 12:58
@sfc-gh-lwilby-1
sfc-gh-lwilby-1 requested a review from a team as a code owner September 24, 2026 12:58
@sfc-gh-lwilby-1 sfc-gh-lwilby-1 added the ai-final-review If applied to PR or issue will run AI review workflow with the latest generation of AI models. label Sep 24, 2026
@greptile-apps

greptile-apps Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable failure was established.

Summary

Raises Streamlit’s published websockets upper bound to allow 17.x. The workspace lock selects websockets 17.1 on Python 3.11–3.14 and retains 16.1.1 on Python 3.10.

Reviews (1) · Last reviewed commit: "Allow websockets 17.x on Python 3.11+"

@github-actions github-actions Bot removed the ai-final-review If applied to PR or issue will run AI review workflow with the latest generation of AI models. label Sep 24, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR raises Streamlit’s published websockets cap from <17 to <18 so Python 3.11+ environments can install Streamlit next to websockets 17.x (#17097). The workspace lock follows the existing pandas pattern: keep 16.1.x on Python 3.10 and force 17.1 on 3.11+ so CI actually exercises the new major. Min-version CI stays on websockets==12.0.0.

The old <17 bound was the routine next-major policy cap from #15948, not a known incompatibility. Streamlit does not import websockets in production; uvicorn’s websockets-sansio protocol (uvicorn >= 0.44) does.

All four expected reviews completed. Three approved; one requested changes over a mixed uvicorn/websockets pairing. Verification finds that pairing real but not merge-blocking (see Backwards Compatibility).

Product Alignment

This is a packaging/installability change, not a new public API, config option, CLI surface, or UI. specs/AGENTS.md lists DevOps/dependency work and small non-controversial enhancements as not requiring a spec; none is expected.

The user-visible effect is that Python 3.11+ users can resolve streamlit with websockets 17.x. Python 3.10 still cannot install 17.x because upstream requires-python is >= 3.11; Streamlit correctly leaves that to websockets rather than promising 17.x on 3.10. Closing #17097 is reasonable for Streamlit’s constraint, with a note that the reporter’s 3.10 environment remains blocked by websockets, not Streamlit.

Code Quality

The diff is minimal and matches documented dependency policy and the pandas 3.x split:

  • lib/pyproject.toml keeps a single published range (>=12.0.0,<18) with the upper bound on the next unreleased major (lib/AGENTS.md).
  • Root [tool.uv] override-dependencies forces 17.x on 3.11+ so the lock/CI do not stay on 16.1.1, which still satisfies <18.
  • uv.lock was regenerated; requires-dist for streamlit is in sync at >=12.0.0,<18. The python_full_version >= '3.15' fallback to 16.1.1 matches the pandas lock markers and the workspace environments cap (python_version < '3.15').
  • scripts/assets/min-constraints-gen.txt needs no update: it is generated from lower bounds, and the websockets floor is unchanged at 12.0.0.

Complexity is proportionate. No extra abstractions.

Performance

No Streamlit runtime or frontend code changes. Delta queueing, WebSocket flushing, and ping settings in starlette_server.py are untouched. Any 17.x internals difference is upstream; the 17.0 notes describe handshake-level changes (HTTP status responses for malformed handshakes, ISO-8859-1 header encoding) plus an optional Trio path Streamlit does not use. Ping/keepalive in the asyncio path is unchanged, so server.websocketPingInterval handling is unaffected. No Streamlit benchmark is warranted.

Test Coverage

No new tests, which is appropriate for a constraint-only change. Existing coverage actually exercises the new major:

  • lib/tests/streamlit/fips_test.py starts a real Streamlit server and opens a real websockets.sync.client connection to /_stcore/stream. On 3.11–3.14 that is now websockets 17.1 on both client and (via uvicorn) server; on 3.10 it stays 16.1.1.
  • Min-version CI still covers websockets==12.0.0.
  • Playwright e2e covers real browser WebSocket sessions.

That combination covers the floor, the previous major, and the new major. There is still no handshake test for non-ASCII proxy headers (the #16030 failure mode); that gap is pre-existing and is not merge-blocking.

Backwards Compatibility

Widening <17 to <18 is additive: every previously allowed version remains allowed. Python 3.10 still resolves to 16.1.x. Existing 12.x–16.x installs keep working.

Reviewers disagreed on one newly permitted combination: websockets 17.x with uvicorn 0.30–0.51. That pairing can abort /_stcore/stream when a proxy injects non-ASCII identity headers (#16030; uvicorn added the ISO-8859-1 round-trip in 0.52.0). It is a real mixed-version caveat, not a reason to block this cap bump:

  • Fresh installs and this repo’s lock resolve uvicorn 0.53.0, which includes the fix.
  • Raising the published uvicorn floor from 0.30.0 to 0.52.0 would invalidate currently valid 0.30–0.51 environments that never need websockets 17; that is a larger compatibility change than this additive widen and should be a follow-up if product wants it.
  • PEP 508 cannot express “websockets>=17 requires uvicorn>=0.52” without extras. The same mixed-version shape already existed for uvicorn 0.30 + websockets 16.x.

uvicorn < 0.44 still selects "auto" / websockets.legacy, which still ships in 17.x (removal targeted for 2030). That combination is not in CI and is pre-existing in shape.

Security & Risk

No security-sensitive Streamlit code changed. websockets is already a required runtime dependency; this only widens the allowed range. Lockfile hashes pin 17.1, and exclude-newer = "24 hours" still applies.

Security posture of 17.x is not a regression: 16.1 stripped Authorization/Cookie/Proxy-Authorization on cross-origin redirects, and 17.0 returns HTTP 414/431 when a handshake exceeds security limits instead of dropping the connection. Streamlit’s XSRF, cookie signing, and session-to-identity binding sit above the ASGI boundary and are untouched.

The only material regression risk is the mixed uvicorn < 0.52 + websockets 17.x path behind non-ASCII proxy headers, discussed above. Default and CI stacks are on the safe pairing.

External test recommendation

  • Recommend external_test: Yes (indirect; no new marked tests needed on this PR)
  • Triggered categories: 3. Websocket handshake and session transport (indirect)
  • Evidence:
    • lib/pyproject.toml: raising the cap to <18 changes the library that implements the WebSocket opening handshake and ping/pong keepalive beneath uvicorn’s websockets-sansio protocol. websockets 17.0 uses ISO-8859-1 header encoding and replies with HTTP 405/414/431/505 on malformed handshakes.
    • pyproject.toml / uv.lock: Python 3.11+ environments now resolve to websockets 17.1, so hosted deployments on those versions get the new major.
    • No Streamlit source under lib/streamlit/web/server/ changed, so this is an indirect hit only; categories 1, 2, and 4–11 are not hit.
  • Suggested external_test focus areas:
    • WebSocket upgrade to /_stcore/stream through a reverse proxy / hosted ingress on Python 3.11+, including a non-ASCII display-name header (e.g. Authelia/Authentik Remote-Name / X-Authentik-Name).
    • App load does not stick on “Please wait…”; session reconnect still works.
    • server.trustedUserHeaders / st.context.headers still expose those forwarded values.
  • Confidence: Medium-High
  • Assumptions and gaps: Existing @pytest.mark.external_test coverage in e2e_playwright/mega_tester_app_test.py already drives a hosted session over the WebSocket, so running the external suite once on this branch is sufficient. One review treated this as a no-hit because no Streamlit server source changed; the any-hit policy still applies because the transport library behind the handshake changed. Assumes the external image has uvicorn >= 0.52 (the safe pairing). The uvicorn < 0.52 + websockets 17.x combination is not in CI.

Accessibility

Not applicable. No frontend, markup, styling, or interaction changes.

Readability

PR title — [fix] Allow websockets 17.x is specific, matches change:bugfix, and stands alone. Optional: [fix] Allow websockets 17.x on Python 3.11+ would surface that #17097 was filed on 3.10; the body already states that clearly.

PR description — Leads with the change, explains the old policy cap, documents the Python 3.10 consequence up front, and gives a concrete testing plan. Optional wording: replace “unused next-major policy cap” with “routine next-major policy cap.” Optional addition after the 3.10 note: uvicorn 0.52.0+ is the pairing that keeps the #16030 non-ASCII proxy-header path working with websockets 17.

lib/pyproject.toml (comment above the constraint) — “Websockets 17.x requires Python >= 3.11.” matches the pandas comment at line 69. Optional clearer form: “Required for uvicorn WebSocket support. 17.x needs Python >= 3.11; 3.10 stays on 16.x.” Consistency with pandas is a valid reason to leave it.

pyproject.toml override comments — The generalized version-split comment correctly attributes the Python 3.11 floor to both packages. No rewrite requested.

No naming or docstring issues; no Python source changed.

Recommendations

  1. Optional follow-up: raise the published uvicorn floor to >=0.52.0 (and min-version coverage) if product wants to forbid websockets 17 with uvicorn 0.30–0.51. Do not block this cap bump on that larger compatibility change.
  2. When closing #17097, note that Python 3.10 users still cannot install websockets>=17.1 because 17.x requires Python >= 3.11.
  3. Optional: add a handshake regression that sends a non-ASCII proxy header to /_stcore/stream so #16030 cannot return silently on a future websockets major.
  4. No new unit tests, no new @pytest.mark.external_test cases, and no spec are needed for this change.

Verdict

APPROVED: A correct, minimal dependency-range widening that follows the published-range policy and the pandas Python-version split, with CI locked to websockets 17.1 on 3.11+. The uvicorn < 0.52 pairing is a real mixed-version caveat for a follow-up, not a merge blocker.


This is an automated AI review by cursor-grok-4.6-xhigh. Please verify the feedback and use your judgment.

This review also includes 2 inline comment(s) on specific code lines.

Comment thread lib/pyproject.toml Resolved
Comment thread pyproject.toml Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved by AI final review (workflow run).

@github-actions github-actions Bot removed the ai-qa-test If applied to PR, an AI qa testing will run on the feature implemented in the PR. label Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ AI QA Testing Failed

The AI QA testing job failed to complete. Please check the workflow run for details.

You can retry by adding the 'ai-qa-test' label again or manually triggering the workflow.

@sfc-gh-lwilby-1

Copy link
Copy Markdown
Contributor Author

Verified that external testing will run for this based on the nightly.

@github-actions

Copy link
Copy Markdown
Contributor

QA Report: Allow websockets 17.x

Summary

Overall status

PASS

Streamlit runs correctly on websockets 17.x. App load, widget reruns, session state, fragments, file upload, media, forms, health, and client disconnect/reconnect all worked. Debug server started cleanly. No user-facing regressions found.

Test results

Passed tests

ID Scenario Notes
F1 Installed websockets version is 17.x UI and uv run python both report websockets 17.1
F2 App load over WebSocket data-test-connection-state=CONNECTED, script notRunning, app_loaded: true
F3 Debug server starts cleanly Uvicorn started on :::8501; no websocket handshake/protocol errors at startup
F4 Widget interactions trigger reruns Button, text input, slider (25→26), and checkbox all updated over WS
F5 Session state persists across reruns persistent_state survived subsequent increment clicks
F6 Fragment / partial rerun frag_count incremented; outer full_run_id did not
F7 File upload qa_upload.txt content hello websockets 17 displayed
F8 Media render Generated image visible via /media/ URL
F9 Form submit over WebSocket form_submitted: submitted-over-ws
E1 Empty text input hello_name: (empty); no exception
E2 Rapid successive widget clicks Two increment clicks both applied
E3 Keyboard rerun (r) full_run_id incremented; persistent state and fragment count kept
E4 Health HTTP endpoint still works GET /_stcore/health returned 200 while WS session was live
V1 Default rendering after load Headers, widgets, version text visible; no exception/toast
V2 Connection status widget idle Connected; no leftover "Connecting" status
V3 No exception UI stException not attached after all interactions; no toasts
I1 Client disconnect then reconnect disconnectWebsocket() observed CONNECTING then CONNECTED; session state and uploaded file persisted
I2 Interact after reconnect Increment button still worked while CONNECTED
I3 Logging during WS traffic Backend log has no ERROR/Exception/Traceback after the full suite

Failed tests

None.

Blocked tests

None.

Issues found

None.

Early Playwright failures on F4/E1/F9 were test-harness locator mistakes (get_text_input returns the widget container, not the <input>; Streamlit sliders use input[type=range], not role=slider). Those were not product bugs. After the harness was fixed, all cases passed.

Frontend logs contain expected WebSocket onclose and Cannot send rerun backMessage when disconnected from server messages during I1's intentional window.streamlitDebug.disconnectWebsocket() cycle. They are not regressions.

Recommendations

  • No product fix required for this PR from QA.
  • Python 3.10 remaining on websockets 16.1.x is documented and expected; do not treat it as a QA failure.
  • Optional follow-up (out of scope here): a proxy/non-ASCII handshake check related to Streamlit websockets 16.1 issue #16030 / uvicorn#3035, if CI can host a header-mutating proxy.

Notes

  • Changed files in this PR are dependency-range only (lib/pyproject.toml, pyproject.toml, uv.lock). Streamlit does not import websockets in production app code; uvicorn uses it via ws="websockets-sansio".
  • Workspace lock pins websockets 17.x on Python 3.11+; this runner is Python 3.14.7 with websockets 17.1.
  • Agent-wiki docs for PR 17113 were not present.
  • Camera input and non-ASCII proxy handshake were not exercised (out of scope / not feasible in this runner).
  • Screenshots: initial_load.png, final_state.png, and per-case *_pass.png in this directory.

This is an automated QA report by cursor-grok-4.6-xhigh.

@sfc-gh-lwilby-1
sfc-gh-lwilby-1 merged commit 3d527fe into develop Sep 25, 2026
109 of 110 checks passed
@sfc-gh-lwilby-1
sfc-gh-lwilby-1 deleted the chore/raise-websockets-upper-bound branch September 25, 2026 08:07
sfc-gh-lwilby-1 added a commit that referenced this pull request Oct 8, 2026
## Describe your changes

Logs a startup warning when `websockets` 17+ is paired with `uvicorn` <
0.52.0 . Follow-up to allowing websockets 17.x (#17113). That mix is a
legal install, but uvicorn can abort the `/_stcore/stream` handshake
when a reverse proxy forwards non-ASCII identity headers (#16030).
uvicorn fixed the round-trip in 0.52.0
([Kludex/uvicorn#3036](Kludex/uvicorn#3036)).

The warning can also fire for operators who will never see a non-ASCII
proxy header.

## GitHub Issue Link (if applicable)

#16030

## Testing Plan

- [x] Unit Tests (JS and/or Python)
- [ ] E2E Tests
- [ ] Any manual testing needed?

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.

Made with [Cursor](https://cursor.com)

---------

Co-authored-by: lawilby <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for websockets >= 17.x

3 participants