Skip to content

fix #21: [12] uvicorn.run(reload=True) is hardcoded regardless of environment - #45

Merged
CuriosityQuantified merged 1 commit into
mainfrom
feat/uvicorn-reload-env-21
Aug 9, 2026
Merged

CuriosityQuantified merged 1 commit into
mainfrom
feat/uvicorn-reload-env-21

Conversation

@CuriosityQuantified

Copy link
Copy Markdown
Owner

Closes #21

Problem

main.py called uvicorn.run("api.app:app", reload=True, ...) unconditionally. In production, reload=True makes uvicorn spawn a file-system watcher over the whole project tree and restart workers on any file change — wasting CPU, breaking graceful shutdown, interfering with container/PaaS restart policies, and potentially exposing source paths through watcher errors. env.example already defined RELOAD but it was never read.

Fix

  • Add a pure, importable helper resolve_reload() -> bool in main.py = os.getenv("RELOAD", "false").lower() == "true" (defaults OFF; only case-insensitive "true" enables reload).
  • Wire uvicorn.run(reload=resolve_reload()); no other kwargs changed.
  • env.example: document the now-wired RELOAD behavior and the production expectation (leave unset/false in prod).

Tests & CI

  • New hermetic, stdlib-only regression suite tests/unit/test_uvicorn_reload_regression.py (17 cases): default-off when unset, case-insensitive true variants, non-true values stay off, bool return type, and static guards that main.py no longer hardcodes reload=True and is wired to resolve_reload().
  • Added a named Run uvicorn reload gating regression step in the unit-tests job. The existing 3-job CI shape (unit-tests / regressions / build) is preserved — no code-graph job (repo has no graph).

Local gates (all green)

  • Focused test: 17 passed.
  • Full CI-equivalent unit gate (with the 8-test deselect list): 226 passed, 1 skipped, 8 deselected.
  • import main is side-effect-free; resolve_reload() defaults to False.
  • npm run build: success.

Scope

Focused on environment-driven uvicorn reload behavior and its regression/documentation/config coverage. No unrelated changes. Graphify: not applicable (repo has no .mcp.json/graphify-out).

🤖 Generated with Claude Code

main.py hardcoded reload=True in uvicorn.run(), so production always
spawned a file-system watcher over the whole project tree: CPU overhead,
broken graceful shutdown, interference with container/PaaS restart
policies, and potential source-path disclosure via watcher errors.

Add a pure, importable helper resolve_reload() that reads the RELOAD env
var and defaults OFF (only case-insensitive "true" enables reload), and
wire uvicorn.run(reload=resolve_reload()). env.example already defined
RELOAD but it was never read; document the newly-wired behavior there.

Regression coverage: tests/unit/test_uvicorn_reload_regression.py
(hermetic, stdlib-only) locks the default-off semantics, case-insensitive
true variants, non-true values, bool return type, and static guards that
main.py no longer hardcodes reload=True. Added a named CI step in the
unit-tests job (3-job shape preserved; no code-graph job).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
save-the-world Ready Ready Preview Aug 9, 2026 6:41pm
sim-local Ready Ready Preview Aug 9, 2026 6:41pm

@CuriosityQuantified
CuriosityQuantified merged commit c2696a8 into main Aug 9, 2026
6 checks passed
@CuriosityQuantified
CuriosityQuantified deleted the feat/uvicorn-reload-env-21 branch August 9, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[12] uvicorn.run(reload=True) is hardcoded regardless of environment

1 participant