Skip to content

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

Open
benedikt-bartscher wants to merge 6 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 6 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

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

  • Evicts stale project configuration modules before probing and loading.
  • Preserves concurrent imports while loading rxconfig.py.
  • Adds regression coverage for import-path ownership, concurrent imports, dependency tracking, and meta-path mutation.

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 loading and dependency recording while resolving the previously reported sys.path and meta-path cleanup failures.
tests/units/test_config.py Adds regression coverage for concurrent imports, caller-owned path entries, dependency recording, and meta-path replacement.
packages/reflex-base/news/6933.bugfix.md Documents the corrected concurrent-import and stale-rxconfig behavior.

Reviews (5): Last reviewed commit: "more reviews" | 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 (1c94886) with main (6b44604)

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

@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