Skip to content

fix(cli): report backend readiness after startup - #7416

Open
kr1shna-exe wants to merge 3 commits into
reflex-dev:mainfrom
kr1shna-exe:fix/7252-backend-startup-status
Open

kr1shna-exe wants to merge 3 commits into
reflex-dev:mainfrom
kr1shna-exe:fix/7252-backend-startup-status

Conversation

@kr1shna-exe

@kr1shna-exe kr1shna-exe commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #7252.

The dev CLI could report a running backend after its worker failed to import the app. Granian readiness now follows successful ASGI lifespan startup.

What changed

  • Report unexpected worker exits while preserving recovery after file changes.
  • Report frontend readiness separately from backend startup.
  • Accept both frontend message formats in reflex-bench.
  • Cover import failures, lifespan failures, delayed startup and repeated recovery with real workers.

Verification

  • Full unit suite: 11,196 passed, 155 skipped; 79.04% coverage.
  • Repository Ruff checks, formatting and Pyright passed. Changed-file pre-commit hooks passed.
  • Real backend-only and combined Reflex CLI runs recovered from import failures. The benchmark driver waited for recovery; frontend HTTP and backend /ping returned 200. All test processes were stopped.

Deployment notes

Tools parsing Granian dev logs should recognize Frontend running at: for the frontend URL and wait for Backend running at: for backend startup. Production and legacy Uvicorn messages are unchanged.

Review in cubic

@kr1shna-exe
kr1shna-exe requested a review from a team as a code owner October 4, 2026 19:46

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread tests/units/utils/test_exec.py Resolved
@greptile-apps

greptile-apps Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining new concern is a misleading, non-blocking startup banner.

Summary

The PR defers Granian’s backend announcement until successful ASGI lifespan startup and reports worker exits while preserving reload recovery.

  • It retains the frontend URL announcement and updates benchmark readiness coverage.
  • Real-worker tests cover startup failures and recovery.

Reviews (3) · Last reviewed commit: "fix(cli): keep the App running at line i..." · Reviewed by Greptile

Comment thread tests/units/utils/test_exec.py Resolved
Comment thread tests/units/utils/test_exec.py Resolved
@codspeed

codspeed Bot commented Oct 6, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 150 untouched benchmarks
⏩ 18 skipped benchmarks1


Comparing kr1shna-exe:fix/7252-backend-startup-status (27ddc54) with main (7970e91)

Open in CodSpeed

Footnotes

  1. 18 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@masenf masenf added the bug Something isn't working label Oct 6, 2026
Comment thread reflex/utils/exec.py Outdated
notify_backend()
if backend_present and should_use_granian():
console.print(
f"Frontend running at: [bold green]{url.rstrip('/')}/[/bold green]"

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.

In dev mode with Granian (the default whenever uvicorn or gunicorn isn't installed), App running at: is never printed now. Nothing replaces it later either: the backend announces itself only through Backend running at:.

Tools outside this repo parse that line. docs/enterprise/testing.md:318 says the reflex-enterprise pytest plugin builds reflex_app.url, including frontend_path, by reading reflex's own "App running at:" line, and its default run_mode is dev. That plugin would stop finding the URL. reflex-bench needed a regex change in this PR for the same reason. The PR's own test confirms the line is gone: test_exec.py:177-178 asserts "App running at:" not in message for granian with a backend.

Fix: keep the App running at: text. One option is to print the frontend line as before and only move the backend line to lifespan startup. If the rename has to stay, treat it as a breaking change for log parsers, with a deprecation path.


Generated by Claude Code

Log parsers (the reflex-enterprise pytest plugin, reflex-bench) read the
frontend URL from it. Only the backend line moves to lifespan startup.
@greptile-apps

greptile-apps Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P2 Premature running banner reflex/utils/exec.py:350 ▶

    run_frontend now displays “App Running” before it launches the frontend process. If startup fails, the terminal still shows a success-sounding banner, which can mislead someone diagnosing the failure. A “Starting” heading would distinguish launch from readiness.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@kr1shna-exe

Copy link
Copy Markdown
Contributor Author

@greptile-apps the "App Running" banner is unchanged from main. This push only reverted my earlier rename so dev output stays the same for anything reading it, so I'm leaving it as is here.

@greptile-apps

greptile-apps Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

That’s fair. Since the App Running banner is intentionally unchanged from main to preserve existing dev output, this PR does not introduce the concern I raised. I’m withdrawing the finding; no change is needed here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dev "reflex run" prints "Backend running at …" / "App running at …" and idles after the app module raised at import

3 participants