Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions reflex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ class Config(BaseConfig):
See the [configuration](https://reflex.dev/docs/getting-started/configuration/) docs for more info.
"""

# Track whether the app name has already been validated for this Config instance.
_app_name_is_valid: bool = dataclasses.field(default=False, repr=False)

def _post_init(self, **kwargs):
"""Post-initialization method to set up the config.

Expand Down
5 changes: 4 additions & 1 deletion reflex/utils/prerequisites.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def _check_app_name(config: Config):
else:
msg += f"Ensure app_name='{config.app_name}' in rxconfig.py matches your folder structure."
raise ModuleNotFoundError(msg)
config._app_name_is_valid = True


def get_app(reload: bool = False) -> ModuleType:
Expand All @@ -184,7 +185,9 @@ def get_app(reload: bool = False) -> ModuleType:
try:
config = get_config()

_check_app_name(config)
# Avoid hitting disk when the app name has already been validated in this process.
if not config._app_name_is_valid:
_check_app_name(config)

module = config.module
sys.path.insert(0, str(Path.cwd()))
Expand Down
Loading