Serialize concurrent frontend dependency installs - #7051
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Merging this PR will not alter performance
Comparing Footnotes
|
Greptile SummaryThis PR serializes frontend installation and web-directory initialization through a reentrant per-project process lock, while making generated package-manager files and procedure caches atomically replaceable.
Confidence Score: 5/5The PR appears safe to merge; the changes since the previous review address the outstanding test-organization requirement without introducing a confirmed regression. The fork-safety revision serializes descriptor transitions around forks, resets inherited ownership in children, and preserves cleanup across acquisition and release paths. Both previous review findings are now fully addressed.
|
| Filename | Overview |
|---|---|
| reflex/utils/frontend_lock.py | Implements reentrant cross-process project locking with guarded raw-descriptor tracking and fork-safe child state reset. |
| reflex/utils/js_runtimes.py | Extends the project lock across the complete frontend installation transaction and stabilizes cache inputs around resolved plugin dependencies. |
| reflex/utils/frontend_skeleton.py | Coordinates web-directory initialization with installs and atomically replaces generated and persisted package-manager files. |
| packages/reflex-base/src/reflex_base/utils/decorator.py | Atomically writes procedure caches and safely converts malformed cache contents into cache misses. |
| tests/units/utils/test_frontend_lock.py | Provides focused coverage for contention, reentrancy, crash cleanup, Windows retries, and POSIX fork behavior. |
| tests/units/reflex_base/utils/test_decorator.py | Moves decorator tests into the matching module and covers cache corruption, I/O errors, atomic replacement, and symlink preservation. |
| tests/units/test_prerequisites.py | Tests complete installation transaction locking, cache reuse across processes, initialization exclusion, and atomic lockfile persistence. |
Reviews (3): Last reviewed commit: "Make frontend lock cleanup fork-safe" | Re-trigger Greptile
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Why
Two Reflex processes can currently enter the same frontend install transaction together. Both can mutate
.web, invoke the package manager, overwrite the procedure cache, and persist root lockfiles concurrently. A simultaneous frontend reinitialization can also replace.webduring an install.What changed
.reflex.frontend.lock. POSIX usesflock; Windows uses a retrying one-bytemsvcrtlock. The process-local layer is thread-safe and reentrant, and the OS releases ownership after crashes.initialize_web_directorywith the same lock so it cannot replace.webduring an active install.Atomic replacement guarantees complete-file visibility and preserves the prior file when commit fails; it does not claim power-loss durability without
fsync.Validation
uv run pytest -q tests/units/test_prerequisites.py tests/units/utils/test_utils.py tests/units/reflex_base/constants/test_base.py tests/units/reflex_base/constants/test_installer.py— 344 passeduv run ruff check .— passeduv run ruff format --check .— 1407 files already formatteduv run pyright reflex tests— 0 errors, 0 warningsuv run pre-commit run --all-files— all hooks passed, including Ruff, codespell, Pyright, ty, and BiomeTests cover positive same-project OS contention, complete transaction scope, completed-cache reuse by a waiting process, separate-project concurrency, reentrancy, exceptions and abrupt process exits, Windows contention retries, initialization exclusion, atomic failure recovery, corrupt-cache recovery, permissions, and symlink compatibility.
Checklist
CONTRIBUTING.md