Repository navigation
Preserve registered callbacks passed through state events - #8078
harsh21234i wants to merge 7 commits into
Conversation
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge; no new actionable issue remains. SummaryPreserves registered callbacks passed through state events.
Reviews (2) · Last reviewed commit: "Describe every fix in the news fragment" · Reviewed by Greptile |
Merging this PR will degrade performance by 4.01%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
A string bound to a forwarded callback went through LiteralVar.create, which parses Var markup. A client could send <reflex.Var>hello</reflex.Var> and freeze the worker in that parser. Bind each value as a JSON Var instead, with "<" escaped so the markup parser never sees it when call_script embeds the callback in its script.
Drop _InvalidEventCallbackError and the two clauses that re-raised it. A callback that cannot be restored now raises ValueError, so the payload falls back to the values as sent and the failure is logged, the same as any argument that does not match its annotation.
No caller passes an event handler to add_args, so its signature goes back to *args: Var. The one caller that needs it, EventHandler.__call__, turns an uncalled handler argument into a partial event itself.
Pin the payload compiled for a handler passed uncalled as an argument, and that a trigger fills the parameter a keyword binding left free.
Closes #4894.
Passing an uncalled handler to another event tried to compile it as a no-argument conditional event. A partially applied event declared in a page could reach the receiving handler as a plain browser object, so forwarding it to
rx.call_scriptlost the callback.Bind uncalled handlers as partial events. When a receiving state handler's parameter is annotated as an event callback, restore the browser's event object through the registration context. Ordinary payload dictionaries keep their existing semantics. Bound arguments are validated against the registered handler and keep their names when a subsequent trigger supplies the remaining arguments.
The new Chromium regression fails on main and exercises server-initiated forwarding, browser-initiated forwarding and partial application. A unit regression covers registry resolution, named binding, ordinary payloads and malformed callback references.