-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix fragment runtime errors for just removed fragments #9965
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
Conversation
0f93041 to
19912dc
Compare
kmcgrady
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, the approach seems solid. My only question is should we consider clearing the fragment id from the past after some time (or after a rerun or two without it?). Just seems like this storage can get arbitrarily large. We may also be fine with this because the storage is in the AppSession which is tied to a browser tab living (which is very unlikely). Just wondering if we can make a guarantee where we know for sure that we should never see an old fragment id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might benefit from a comment to clarify how this relates to the fragments case (like the one from the PR description)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, I have added a comment to explain this in more detail
19912dc to
52908ce
Compare
|
Yeah that's a great point. I think the best options might be to use a cache counter and clear them after |
52908ce to
d8fa998
Compare
9d62354 to
6ac2fbf
Compare
|
PR looks good, but it seems that the PR contains two slightly independent fixes. Would it be possible to split it into two PRs that might make it easier to handle follow-up issues that might arise from the fixes.
I'm leaning slightly more towards keeping it simpler, just always logging it to the console and never raising an exception that's shown to the user. I don't think it adds a lot of benefit to show this error to the user in any situation and the developer can see it in the logs -> and adding the additional complexity just to be able to show the error sometimes on UI doesn't feel to be worth it. |
6ac2fbf to
9be0735
Compare
|
Good points, I have started to split the PRs, here is the first one: PR-10130 to change from throwing an error to just showing a log |
…10130) ## Describe your changes After the discussion in context of this PR: #9965, we want to show a log instead of raising an error in all cases to keep it simple and not introduce another list / more tech debt. ## GitHub Issue Link (if applicable) ## Testing Plan - Unit Tests (JS and/or Python) - Remove a couple of unit tests that checked for the exception to be thrown --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
…treamlit#10130) ## Describe your changes After the discussion in context of this PR: streamlit#9965, we want to show a log instead of raising an error in all cases to keep it simple and not introduce another list / more tech debt. ## GitHub Issue Link (if applicable) ## Testing Plan - Unit Tests (JS and/or Python) - Remove a couple of unit tests that checked for the exception to be thrown --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
Describe your changes
Split into following PRs: #10132, #10147, #10130
Closes #9921
In issue #9921, the problem is that the
st.reruncall inside of the dialog triggers a rerun. If you click on the button again before the dialog closes, another RequestRerun is sent to the server. By the time this second request is processed, the full-app rerun has already happened and cleared the fragment storage. So when the second RequestRerun is processed, the fragment id cannot be found anymore and the error is thrown.This PR adds a
previous_fragment_idslist to theFragmentStorageand only raises an error if the fragment id has never been seen. Otherwise, just log is emitted.Discussion 1: We could always just emit a log and do not introduce the additional list.
After making this change, another issue surfaced: the error itself was gone, but the Dialog stayed open sometimes. There are two different root causes for this (both race conditions interplaying with the ScriptRunner threads etc.):
forward_msg_queue, the FinishedScript type was always set toSTOPPED_EARLY_FOR_RERUN. Now, the status is not changed for full app reruns by fragment runs. This is correct since a fragment indeed does not stop full app reruns. This only happens when the fragment run is so fast that the browser queue is not cleared yet.app_session, a fragment run might create a newScriptRunnerwhen the current ScriptRunner is in stateSTOPPED(in this case,successhere isfalseand the new ScriptRunner is created). This will lead to all events from the previous script runner being ignored (see here). When the full app rerun ScriptRunner is done (STOPPED) but its events are not processed before the new ScriptRunner is created, its finished message is not sent to the frontend and no cleanup is happening.GitHub Issue Link (if applicable)
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.