RuntimeError: "Could not find fragment with id ......"

Hi All,

I have a web app that I created using Streamlit and deployed on Azure Web App Service. Previously, I did not experience any issues, but recently, after I started using @st.dialog(" ") and @st.cache_resource for logging, I began encountering an error. It’s important to note that I’m not using any fragments in my code.

Occasionally, when I open the web app, I encounter the following error:

RuntimeError: Could not find fragment with id 528f508d48a849e97fb463d969cf2108
Traceback:
File "/tmp/8dccee146dcecba/antenv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 85, in exec_func_with_error_handling
    result = func()
             ^^^^^^
File "/tmp/8dccee146dcecba/antenv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 560, in code_to_exec
    raise RuntimeError

Interestingly, the error disappears if I refresh the page, but it tends to pop up later again. I have encountered the error in the Azure Web App log stream as well:

Connected!
2024-09-11T21:15:49  Welcome, you are now connected to log-streaming service.Starting Log Tail -n 10 of existing logs ----/appsvctmp/volatile/logs/runtime/container.log
2024-09-11T17:34:06.8741032Z     raise RuntimeError(
2024-09-11T17:34:06.8741074Z RuntimeError: Could not find fragment with id 528f508d48a849e97fb463d969cf2108

Does anyone have any suggestions on how to diagnose or resolve this issue? Any insights would be greatly appreciated!

Streamlit version: Streamlit, version 1.38.0
Python version: Python 3.11.2

Thanks in advance!

1 Like

I have the same issue. How can we trace fragment ids to debug these errors?

A dialog is a fragment, so that’s likely to be the fragment in question. :slight_smile:

There were fragment bug fixes in both version 1.39.0 and 1.40.0. Would it be possible for you to confirm if this still happens on the latest version of Streamlit?

@mathcatsand I am currently using streamlit 1.40.0 and regularly get these errors:

Traceback (most recent call last):
  File "...\streamlit\runtime\scriptrunner\script_runner.py", line 88, in exec_func_with_error_handling
    result = func()
  File "...\streamlit\runtime\scriptrunner\script_runner.py", line 563, in code_to_exec
    raise RuntimeError(
RuntimeError: Could not find fragment with id c0737d868aa8bcf378c7f91d8bd89269
2024-12-17 10:54:25.355 Uncaught app exception
Traceback (most recent call last):
  File "...\streamlit\runtime\scriptrunner\script_runner.py", line 117, in get
    return self._fragments[key]
KeyError: 'c0737d868aa8bcf378c7f91d8bd89269'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "...\streamlit\runtime\scriptrunner\exec_code.py", line 88, in exec_func_with_error_handling
    result = func()
  File "...\streamlit\runtime\scriptrunner\script_runner.py", line 563, in code_to_exec
    raise RuntimeError(
RuntimeError: Could not find fragment with id c0737d868aa8bcf378c7f91d8bd89269

Would love to know how to traceback, just getting this error is frustrating.

Are you able to reproduce the error locally, or is this just something that happens on Azure? Can you share your app’s code?

This happens locally for me. My code is pretty long but even a simple code like the below triggers it. At times when using nested fragments, unclear which fragment is causing the error. Very frustrating.


@st.fragment
def right_container():
      
     st.write("**CV Section**")
      
     if "cv_data" not in st.session_state:  
         st.session_state["cv_data"] = []

     ## cv sections
     with st.expander("Contact Details"):
         parts_cols = st.columns(2)
         parts_cols[0].text_input("first name", placeholder="first name")
         parts_cols[1].text_input("last name", placeholder="last name")
         parts_cols[0].text_input("phone number", placeholder="phone number")

   
right_container()
     

What steps do I need to do to reproduce the error? I’m unable to reproduce the error with that code snippet (after adding the Streamlit import statement).

Not entirely sure. Though often it seems to occur after periods of inactivity even when the page is in current view. So if I don’t interact with the page in view (displayed on screen) for some minutes, then click a button the error comes .

Exact same problem here when I access my streamlit app from mobile. When I access it from laptop web browser runs without problem. The app runs on laptop and I access it through wireguard mobile app if this could mean something

@akotronis Please could you file an issue on GitHub with as much information as possible for the engineers to reproduce it? If you have an app that consistently shows this error specifically on mobile view, that is helpful information. If you can specify the OS and browser versions you’re using with the latest version of Streamlit, maybe they can reproduce it. (Make sure it’s the latest version of Streamlit to rule out the recent fragment fixes that have gone out. Even better if you can confirm if the issue exists for the last few versions of Streamlit too, so we know if it’s a regression or independent of the other issues that were fixed.)

@akotronis I also just heard that they merged another change to fragments, so you might want to check out the nightly release and see if how it’s behaving there.

This happens to me all the time if I leave the page I have open in streamlit just sitting there for awhile. The next time I take any action on the page that requires a behind the scenes post back I get the RuntimeError: Could not find fragment with id blah blah error. It is kind of a big deal as nothing will work after that. I have to reload the application in the browser to get going again.

2 Likes

My users are also experiencing this issue, but there seems to be no ‘event’ to trigger it. I suspect this happens whenever the site is idle for too long. If there is an update on what is triggering this please let me know. Currently investigating further to see if I myself can reproduce the issue.

Whenever I’ve encountered the issue I’ve just reloaded the page, and then it works fine.

3 Likes

@Clara2 @Collin_Smith

My God! I thought I was crazy. Nice to see its not just me seeing this issue. Literally not interacting with it for a while brings the error up.

3 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.