Hi everyone,
I’m building a custom React + TypeScript application in Google AI Builder and deploying it directly to Cloud Run using the built-in Deploy button. Overall the workflow is very smooth — except for one major blocker that makes production deployment extremely difficult:
Issue: AI Builder automatically injects its own service-worker.js on every deploy
Each time I click Deploy in AI Builder, the final Cloud Run container ends up containing a folder structure like:
/server
└── service-worker.js ← auto-generated by AI Builder
This file overwrites any service worker I previously added in my project.
Even if I:
-
mirror the same folder structure in my AI Builder project (
Server/Public/service-worker.js), or -
add my own
firebase-messaging-sw.jsinside a/publicfolder (recommended in another thread),
…it still gets ignored or replaced during deployment.
The only way to make my Firebase Cloud Messaging logic work is to:
Manually open the Cloud Run source after every deploy and paste my custom service worker code over the injected one.
This obviously is not sustainable for real development or production.
Why this matters
Service workers are core to:
-
Firebase Cloud Messaging (push notifications)
-
PWAs
-
offline caching strategies
-
background tasks
-
custom routing and asset handling
Right now, anyone using AI Builder for a serious application cannot reliably implement push notifications or custom PWA behavior, because the service worker is:
-
Automatically generated,
-
Not editable, and
-
Overwrites all developer-provided service workers on every deploy.
This creates a frustrating loop where developers cannot control a critical part of their app lifecycle.
What other users are experiencing
Several threads on the Google AI and Serverless forums describe similar scenarios:
-
Developers unable to register their own messaging SW
-
AI Studio automatically creating a root
service-worker.js -
Custom SW files in
/publicor mirrored folder trees not being honored -
Only workaround being manual patching in the Cloud Run container
This issue seems widespread but unresolved.
What we need from Google
1. A way to disable or override the auto-generated service worker
Even just a toggle like:
[ ] Use AI Builder default service-worker.js
would solve this instantly.
2. Documentation on how the injection process works
If certain paths must exist (e.g., /public/service-worker.js), we need to know exactly how to provide our own version that will not be overwritten.
3. Access to edit or replace the injected files
Providing developers control (or even partial override hooks) would make PWAs and Firebase messaging possible without workarounds.
My request
Google AI Builder is incredibly promising — but service workers are essential to modern web apps, and right now the platform prevents developers from using them properly.
Please consider:
-
Allowing custom service worker injection
-
Allowing us to disable the autogenerated SW
-
Or at least documenting how to override it reliably
This would massively improve the experience for anyone building PWAs, Firebase-driven apps, or any app requiring custom SW logic.
Thank you for reading — I really hope this topic sparks discussion and visibility so this can be addressed.