fix(config): keep rxconfig dependencies on same-root reload - #7075
fix(config): keep rxconfig dependencies on same-root reload#7075benedikt-bartscher wants to merge 7 commits into
Conversation
|
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Summary
Fixes #7028
_get_config()evicts every project-local module thatrxconfig.pyimported before each load.rx.App()callsreload_config(), so every backend worker loadsrxconfig.pytwice and re-executes those modules in between. The app code imported beforerx.App()keeps the first copies,sys.modulesholds the second ones, and every class defined in an evicted module now exists twice.For state-defining modules that is the
StateValueErrorfrom #7028. For plain modules it is quieter and worse:pickle.dumps()of an instance of the app's copy fails withCan't pickle <class 'myapp.routes.Route'>: it's not the same object as myapp.routes.Route, because the qualified name resolves to the re-imported class. In our production app that made the auth substate unserializable, so it was never persisted to redis and clients got stuck on hydrate.Changes
rxconfig.pyfrom disk; only its project-local imports are kept. This is option 1 from Reloading a config whose rxconfig.py imports a state-defining module raises StateValueError #7028.reload_config()and a reload in a forked context (theAppHarnessshape).Testing
tests/units/test_config.py: 134 passed. The two same-root tests fail onmain(one with the Reloading a config whose rxconfig.py imports a state-defining module raises StateValueError #7028StateValueError).