Skip to content

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

Open
benedikt-bartscher wants to merge 3 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 3 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 makes rxconfig loading preserve the process import path during concurrent imports and records project-local dependencies only from the loading thread.

  • Prepends cwd temporarily and removes the exact inserted entry afterward.
  • Adds a thread-bound meta-path recorder for rxconfig dependencies.
  • Adds regression coverage for concurrent imports and sys.path ownership.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/reflex-base/src/reflex_base/config.py Reworks rxconfig import-path handling and dependency recording without leaving a blocking correctness issue.
tests/units/test_config.py Adds regression coverage for concurrent imports, caller-owned cwd entries, and dependency attribution.
packages/reflex-base/news/6933.bugfix.md Documents the corrected concurrent-import and stale-module behavior.

Reviews (3): Last reviewed commit: "fix: don't misattribute concurrent impor..." | 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 (ea6e264) with main (d86f167)

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.

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

1 participant