A dev run stopped before its backend loads leaves .web/nocompile, so the next run or export skips the compile

Open Beginner friendly
#7,825 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start in reflex/utils/prerequisites.py at get_compiled_app, then read how App._should_compile handles .web/nocompile and how the backend worker consumes it. Add a regression test in tests/units/utils/test_prerequisites.py that creates the marker and confirms get_compiled_app runs a compile; done means the test fails before the fix and passes after it.

Written by the indexing model from the issue text.

Description

Summary

A dev reflex run creates .web/nocompile so that its backend worker does not compile the app a second time. Only that worker deletes the marker, when it first loads the app. If the run stops before the worker loads the app, the marker stays. The next CLI compile then consumes the marker and skips the compile:

  • reflex run serves the old frontend until a file save triggers a hot reload.
  • reflex export skips the compile, builds the old pages, and exits 0. A deploy from that machine ships the old frontend without a warning.

This is the same family as #7089. The fix in #7125 covered backend-only runs only.

Steps to reproduce

Use any app. Use explicit ports.

  1. Run reflex run once to completion, then stop it.
  2. Run reflex run again. Press Ctrl+C right after App running at: is printed. On a small app the window is about 0.8 s. It is longer on a larger app.
  3. Check that .web/nocompile exists.
  4. Change visible text in a page, for example rx.heading("V1") to rx.heading("V2").
  5. Do one of these:
    • Run reflex run. No Compiling: progress bar is shown. The browser shows V1. It stays V1 until you save a file.
    • Run reflex export --frontend-only --no-zip. The command exits 0, but .web/build/client contains V1, not V2.

Expected

A CLI command that compiles (reflex run, reflex export, reflex compile) always compiles. A marker left by an earlier run does not skip the compile.

Cause

  • run_backend creates the marker when a frontend is present.
  • App._should_compile deletes the marker and returns False. The CLI compile and the backend worker compile both call it, so a stale marker skips whichever compile runs first.

Suggested fix

The CLI paths reach the compile only through prerequisites.get_compiled_app (see the comment in App._compile). The backend worker uses App.__call__. So get_compiled_app can delete a stale marker before it compiles:

     app, app_module = get_and_validate_app(reload=reload)
+    # The marker only lets the backend that a dev run starts skip its compile.
+    # A run stopped before that backend loaded leaves it behind.
+    (get_web_dir() / constants.NOCOMPILE_FILE).unlink(missing_ok=True)
     app._compile(

I tested this change with the steps above:

  • reflex run after the early Ctrl+C compiles and serves the new text.
  • reflex export after the early Ctrl+C builds the new text.
  • A normal dev run still compiles once. The backend worker still consumes the marker and skips its own compile.

The fix needs a regression test, for example in tests/units/utils/test_prerequisites.py: create the marker, call get_compiled_app, and assert that a real compile ran.

Dominant language
Python
Stars
29k
Forks
1.8k
Avg merge
2d 22h
Merged PRs (30d)
143

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reflex-dev/reflex

All issues in reflex-dev/reflex

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.