Breaking Changes
- Calling an
rx.Appinstance (app()) returns a plain ASGI callable instead of aStarletteapp, so the result no longer hasadd_middleware,routesormount. Add Starlette middleware and routes withapi_transformerinstead. (#7624) rx.ModelRegistry.register(Base)is now optional: until a base is registered,reflex dband thealembiccommand line migrate the tables of everyDeclarativeBasesubclass defined at module level or in a class body of a module the app imports. A base meant for another database, or one defined by an installed library, then getscreate_tablein thedb_urlmigrations; register the bases ofdb_urlwithrx.ModelRegistry.register(Base)to leave the others out. An autogenerated revision that drops tables now logs a warning naming them. (#7797)
Features
rx.foreachnow warns at compile time when an item with lifecycle events (on_mount,on_unmount) or hooks of its own is keyed by its index, which is the default. After an item is removed, itson_unmountruns for the item at the last position; set a unique, stablekey, such askey=item.id, orkey=itemfor a list of unique strings, on the component the render function returns. (#7820)
Bug Fixes
- With
REFLEX_OPLOCK_ENABLEDand several production backend workers, an event waiting for a token's lock on one worker no longer stalls for about a tenth of the lock expiration behind another worker's lease. (#7795) - In production, Granian now replaces a backend worker that dies (for example one killed by the OOM killer) instead of stopping the whole server; if a replaced worker dies again within a few seconds, the server still exits. Set
GRANIAN_RESPAWN_FAILED_WORKERS=falseto keep the old fail-fast behavior, for example when a process supervisor restarts the server. (#7803) - The deprecated
rx._x.client_statenow requires anamethat is an ASCII identifier without$, asrx.client_statedoes, and an app whose pages declare one client state name with two different defaults fails to compile with an error naming both declarations. (#7804) - Write
.web/package.json, and the copy kept inreflex.lock/package.json, in the layout bun uses, so the kept file no longer flips between formats and produces whitespace-only diffs. (#7812) reflex db makemigrationsrefuses to add a NOT NULL column whose only default is a dataclassdefault_factory(mapped_column(default_factory=...)on aMappedAsDataclassmodel) and names the column, instead of writing a revision that fails on a table with rows. Give the column aserver_default, a literaldefault=, or make it nullable. (#7815)