404 sometimes when clicking on download button Streamlit on Cloud Run

Dear friends,

I deployed my streamlit app via Google Cloud Run and have been experiencing 404 errors for one of the apps (there’s 16 mini apps in total) [SEO/Social > Bulk SEO Stats Checker]

Download function code:

def excel_download(df):
    towrite = io.BytesIO()
    # write to BytesIO buffer
    df.to_excel(towrite, encoding='utf-8', index=False, header=True) 
    # reset pointer
    towrite.seek(0) 
    return st.download_button("Download", towrite, file_name="Guidesify_App.xlsx", mime='data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')

The app has a download button to export the generated dataframe as a .xlsx file and this works perfectly fine locally but breaks sometimes on GCP. When the 404 error happens, users have to refresh/resubmit their query to generate a new download.

Initially, I thought it could be something to do with Deploying Streamlit on GCP (Cloud Run): problem when using new multipage app feature but applying the suggested fix did not solve this issue.

Was thinking if this has to do with the maximum requests per container field (screenshot attached below).
image

Appreciate any help thanks! :slight_smile: