Hi! I am building a multipage website which mainly involves updating a dashboard from live data which I poll periodically. To manage my polling functions, I have placed them into individual st.fragment
components which runs at a set interval. These components do not contain any rendering functions, and are purely computational. These components are placed into a common module which I import into my different pages.
I noticed that when I use the same fragment across two different pages, and navigate from one to another, I often get an error where the page either does not load (permanent skeleton loading state), or I get a Bad message format 'setIn' cannot be called on an ElementNode
error or something along the lines of Bad 'setIn' index
.
Not sure if it is related, but this seems to occur more often if I have widgets rendered inside columns on the page.
Using this approach, I was able to effectively achieve my desired dashboard look on one page, but once I made it into a multipage app, it became very buggy and crashes very often to the point where it is not usable. I am really hoping someone can provide some insight into this problem, or suggest a better approach for such live data polling use cases.
I cannot share my repository, but this is a very minimal reproduction of the app, in which I have verified the issue still exists:
Streamlit version: 1.38.0
Python version: 3.11
Environment: Local
File directory:
main.py
functions.py
pages
try.py
main.py
:
import streamlit as st
import functions
st.text("hi!")
functions.do_something()
functions.py
:
import streamlit as st
@st.fragment(run_every="0.5s")
def do_something():
count = 0
for i in range(2000):
count += i
try.py
import streamlit as st
import functions
functions.do_something()
c1, c2 = st.columns(2)
with c1:
st.text("hmm")
with c2:
st.text("hi")
The issue occurs less often with this reproduction as it is really minimal, but if you toggle between the two pages quickly enough the problem is bound to happen.
Would really appreciate if someone could help me with this!