Repository navigation
Raise when an event handler is awaited outside any client's event #7821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+667
−28
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
922af06
Raise again for mistaken handler return values; warn when a frontend …
claude ed2ee89
Hint to call an uncalled event creator in the invalid return/yield error
claude 9679a8f
Address review feedback; give the on_event benchmark a real future
claude 83a3043
Raise when a handler is awaited outside any client's event
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| An event handler may return a value that is not an event, which backend code that `await`s the handler receives; returned events still chain and a returned coroutine still raises. Returning `self.other_handler` (meant `type(self).other_handler`), an uncalled event creator such as `rx.redirect`, or a list holding one raises the "must only return/yield" `TypeError` again, as in 0.10, instead of silently doing nothing; for an uncalled event creator the error asks "Did you mean to call it: rx.redirect(...)?". A non-event value returned by a handler that an event trigger such as `on_click` ran is dropped, and in dev mode a warning names the handler once. |
1 change: 1 addition & 0 deletions
1
packages/reflex-base/news/+await-handler-without-token.bugfix.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Awaiting an event handler in an API route or other request code outside `app.modify_state` now raises `EventHandlerTypeError` instead of running it on one state shared by every caller. |
1 change: 1 addition & 0 deletions
1
packages/reflex-base/news/+mistaken-handler-return-values.bugfix.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| An event handler may return a value that is not an event, which backend code that `await`s the handler receives; returned events still chain and a returned coroutine still raises. Returning `self.other_handler` (meant `type(self).other_handler`), an uncalled event creator such as `rx.redirect`, or a list holding one raises the "must only return/yield" `TypeError` again, as in 0.10, instead of silently doing nothing; for an uncalled event creator the error asks "Did you mean to call it: rx.redirect(...)?". A non-event value returned by a handler that an event trigger such as `on_click` ran is dropped, and in dev mode a warning names the handler once. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.