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 .