TypeError: Failed to fetch dynamically imported module in GCP Cloud Run

Up until recently, I have been using Google Cloud Run to deploy a Docker image of my app without any issues. Recently my team did a big PR that included some new functionality that seems to have caused some weird issues to manifest in our staging deployment that I can’t figure out.

Specifically, we see many native streamlit components showing TypeError: Failed to fetch dynamically imported module: url/file.js errors. We also are seeing custom streamlit components like st-auth and streamlit_searchbox timing out and never rendering. However, here are the weirdest parts:

  1. As soon as we use Custom Domain Config to enable opening the app at a custom subdomain we own, these errors start manifesting.
  2. If we tag the Cloud Run deployment revision in our service and go to the URL generated by the tag, it is all working fine.3.
  3. If we don’t cause an st.dialog call to pop a modal (which can be avoided if the user is logged in when the app loads), then many of the widgets render fine, but the custom ones still timeout and weirdly some native widgets (e.g. st.numeric_input and st.checkbox) generate these errors still
  4. If we open the deployed app, at our custom domain, in Safari or Firefox instead of Chrome, everything is fine.
  5. Most of our widgets and modal logic were present in our previous deployment which works fine in all browsers

The “custom subdomain breaking, but not if you view it in Safari/Firefox” part is particularly confusing me and suggests it’s something to do with Google Cloud Run custom domain config nuances interacting with Chrome, but I have no idea what the core issue is, why it is manifesting now after multiple successful deployments, or how to remedy it. Not sure, given the complexity of our app and the fact that earlier versions were operating fine (and that it is proprietary not open source code), how much specific code context I can provide sadly, but see screenshots below. We have not added any new dependencies since the last working version.