Hotfix: force uvicorn h11 HTTP parser (Vercel 400 on POST /_dash-update-component) - #27
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Problem
Every
POST /_dash-update-componentreturns HTTP 400 on the Vercel container deployment. The Dash shell (GET /) serves, butdash.page_containernever populates, and the browser shows secondary renderer errors (Failed to execute 'text' on 'Response': body stream already read) — Dash's error handler tripping over the same 400 body.Root cause
dash_app/server.pycalleduvicorn.run(...)without anhttpargument, so uvicorn usedhttp="auto"and silently selects the httptools parser whenever it is importable. httptools is not a declared dependency (requirements.txthas plainuvicorn), but it reaches container images transitively, anduvicorn>=0.30.0resolves to current releases (0.46+) where the httptools path rejects valid proxy-generated request shapes with400 Invalid HTTP request received.(uvicorn discussion #2934, PR #3097 — absolute-form request targets crash httptools'sraw_path.decode("ascii")onpath=None). h11 accepts the same bytes. Vercel's edge proxy is exactly the Node-based client class in those reports.Local verification (before the fix)
Raw-socket replay of proxy-shaped requests against uvicorn 0.52.4 + httptools 0.8.0:
Invalid HTTP request received.The 400 is emitted by uvicorn's protocol layer (server log:
WARNING: Invalid HTTP request received.) before any app code runs — matching the Vercel runtime log signature. After forcinghttp="h11", the same bytes reach the application layer (404/500 app-level answers, no parser-level 400), and the real combined server boots, serves/health200 and the Dash shell.Fix (smallest possible)
dash_app/server.py:uvicorn.run(..., http="h11")— h11 is uvicorn's own hard dependency and accepts the affected request shapes.tests/test_deployment_contract.py: two focused contract tests —uvicorn.runcall passeshttp="h11";H11Protocoleven when httptools is importable (simulated transitive install).Scope
No changes to Dash page logic, Vercel routing, Dockerfile, or dependencies.
backend/main.py(desktop-only backend entrypoint, not deployed) intentionally left as-is.Validation
1174 passed, 15 skipped(Python 3.12 venv,pip install -e .[dev]).ruff check .clean.