Skip to content

fix(config): load rxconfig with cwd prepended - #6933

Open
benedikt-bartscher wants to merge 8 commits into
reflex-dev:mainfrom
benedikt-bartscher:fix-config-syspath-race
Open

fix(config): load rxconfig with cwd prepended#6933
benedikt-bartscher wants to merge 8 commits into
reflex-dev:mainfrom
benedikt-bartscher:fix-config-syspath-race

Conversation

@benedikt-bartscher

@benedikt-bartscher benedikt-bartscher commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Review in cubic

… sys.path, racing concurrent first-time imports

_load_config cleared sys.path down to the cwd for the duration of the
rxconfig import, so any concurrent first-time import in another thread
failed with ModuleNotFoundError (e.g. the lazy granian import when the
backend starts while another thread loads the config). Prepending the cwd
keeps the same resolution priority without blinding other threads.

Dropping the clear also removes the except-retry fallback, which had been
papering over a second bug: find_spec("rxconfig") answers from sys.modules,
so a leftover module from another project directory faked the existence
probe. Evict rxconfig from sys.modules before probing instead.
@benedikt-bartscher
benedikt-bartscher marked this pull request as ready for review August 23, 2026 17:59
@benedikt-bartscher
benedikt-bartscher requested a review from a team as a code owner August 23, 2026 17:59
@greptile-apps

greptile-apps Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR changes config loading to prepend the current project directory without replacing the process-wide import path and introduces thread-scoped dependency recording.

  • Removes stale rxconfig and project-local dependencies before reload.
  • Keeps a non-resolving import recorder installed across config loads.
  • Adds regression coverage for concurrent imports, path ownership, dependency tracking, and rebuilt meta paths.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/reflex-base/src/reflex_base/config.py Reworks config import-path handling and dependency recording; the previously reported path-removal and meta-path-cleanup defects are fixed at the current head.
tests/units/test_config.py Adds focused regression coverage for the config-loader concurrency and cleanup behavior.
packages/reflex-base/news/6933.bugfix.md Documents the concurrent import-path failure and stale-config behavior addressed by the implementation.

Reviews (7): Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." | Re-trigger Greptile

Comment thread packages/reflex-base/src/reflex_base/config.py Outdated
Comment thread tests/units/test_config.py
@codspeed-hq

codspeed-hq Bot commented Aug 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing benedikt-bartscher:fix-config-syspath-race (e6b2b06) with main (f7c848f)2

Open in CodSpeed

Footnotes

  1. 8 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.

  2. No successful run was found on main (45b8ed5) during the generation of this report, so f7c848f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@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

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

Re-trigger cubic

Comment thread packages/reflex-base/src/reflex_base/config.py
Comment thread packages/reflex-base/src/reflex_base/config.py Outdated

@abulvenz abulvenz 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.

Thanks, nice finding. I would improve on the in-code-comment as annotated. In the tests those comments can help to understand why that test is needed.

Comment thread packages/reflex-base/src/reflex_base/config.py Outdated
Comment thread packages/reflex-base/src/reflex_base/config.py Outdated
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.

2 participants