Fix /track-ws 404: install a WebSocket backend (websockets)#6
Merged
Conversation
Bare `uvicorn` ships no WebSocket protocol library — they live in the `uvicorn[standard]` extra. Under gunicorn's UvicornWorker that means every `/track-ws` upgrade is rejected with "No supported WebSocket library detected" and returns 404, so live letter tracking never worked in the deployed service (the test suite missed it because Starlette's in-process TestClient does WebSockets without uvicorn's backend). Depend on `websockets` directly — lighter than the full `[standard]` extra (no uvloop/httptools/watchfiles) and all the worker needs to accept the upgrade. Add a guard test asserting a ws backend is importable so this can't silently regress.
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.
Bug
Live letter tracking never worked in the deployed service. Every
/track-wsWebSocket upgrade returns 404 with this in the gunicorn log:Root cause
uvicornis declared without the[standard]extra, so the uv2nix-built env contains no WebSocket protocol library (websockets/wsproto).websocketsappears inuv.lockonly as uvicorn's unselected extra, so it's never installed. Under gunicorn'sUvicornWorker, the upgrade can't be handled → 404 for every serial.This slipped through because the test suite uses Starlette's
TestClient, which performs WebSockets in-process and does not exercise uvicorn's protocol backend.Fix
websockets>=14,<17as a direct dependency (lighter than the fulluvicorn[standard]extra — no uvloop/httptools/watchfiles — and all the worker needs to accept the upgrade), and re-lock.test_uvicorn_has_websocket_backendasserting a ws backend is importable, so this regression can't ship silently again.Checks
checks.lint(ruff) +checks.typecheck(mypy) clean.