Repository navigation
fix(dev): let the API hot reload while the web app is open - #51
Merged
Merged
Conversation
The web app keeps /api/v1/events open, and uvicorn waits for open connections before reloading, so with fastapi dev a reload hung until the browser was closed. start.sh runs uvicorn with a 3 s graceful shutdown timeout, watching only app/ (not a local .venv). local-shared-data/openapi.json is what the dev API writes for the dev web app; tracked, it was a stale 800 KB diff after every make dev. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ja26f8Npk3M6ixFhE1WEfe
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.
Requested by Adeel · project thread
Description
Before: in
make dev(ormake start-backend), saving a backend file while the web app was open made the API stop at "Waiting for connections to close" and stay down: the web app got 502s until the browser tab closed. Everymake devalso left an 800 KB diff inlocal-shared-data/openapi.json.After: the API reloads within a few seconds whether or not the web app is open, and
make devleaves the git tree clean.Motivation and Context
The web app keeps
/api/v1/events(server-sent events) open, and uvicorn waits for open connections before it reloads.fastapi devhas no option for a graceful-shutdown timeout, sostart.shnow runsuvicorn app.main:app --reload --reload-dir app --timeout-graceful-shutdown 3. Watching onlyapp/also stops a local.venvinfastapi_backend/from triggering reloads.local-shared-data/openapi.jsonis the schema the dev API writes for the dev web app container. It was tracked but stale, so it is now ignored (.gitkeepkeeps the folder).nextjs-frontend/openapi.jsonremains the tracked schema.Steps to reproduce (if appropriate):
make dev, open the web app, then touch any file infastapi_backend/app. Before: the API never comes back. After:Cancel 1 running task(s), timeout graceful shutdown exceeded, thenApplication startup complete. I checked this in the dev stack.Types of changes
!in the title)Checklist:
make hookschecks it on commit).docs/accordingly.## UnreleasedinCHANGELOG.md.GitHub Actions can't run on this repo right now, so Adeel approved merging on local checks.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Ja26f8Npk3M6ixFhE1WEfe
Generated by Claude Code