kmcgrady / streamlit-autorefresh

An autorefresh component for Streamlit apps
MIT License
176 stars 16 forks source link

st_autofresh breaks session state + causes strange experimental_rerun behavior #7

Closed Quajijalon closed 1 year ago

Quajijalon commented 1 year ago

In the following code snippet, once the count == 1, an error will occur stating that the attr 'a' is not in the session state.

image

Not only has the session state been emptied, the experimental rerun doesn't seem to run from the start, otherwise it would have re-added that attr to the session state.

kmcgrady commented 1 year ago

Hey @Quajijalon ! Thanks for the report. So I tried this example code, and I did not get the error. I think you meant count == 0? I don't think there's much I can do because I think it's related to Streamlit's Experimental Rerun. See https://github.com/streamlit/streamlit/issues/5537

Essentially, session state changes in a script run seem to be lost on experimental rerun, which could be causing the issue.

Hope that helps. I recommend commenting on the Streamlit issue.