I have a working Firebase application (Sveltekit to be specific).
The application works most of the time before it all falls apart. Specifically, the functions part of the application just totally disintegrates.
When you deploy the Sveltkit application it uses both hosting and functions. The server side code is compiled into a single worker.js and it handles client requests.
Just after 14:00 UTC I start to receive the following errors for the function,
Error: Not found: /service-worker.js
at resolve2 (file:///workspace/index.js:2750:18)
at resolve (file:///workspace/index.js:2583:34)
at Object.handle (file:///workspace/chunks/hooks.server.js:42:16)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async respond (file:///workspace/index.js:2581:22)
at async handle (file:///workspace/node_modules/firebase-frameworks/dist/sveltekit/index.js:13:22)
Requests to my function is authenticated by hooks.server
and without hooks.server
retrieving the authentication token and verifying it, everything goes into meltdown as I described with the functions denying all requests.
{
insertId: "66f4196c00064965dcbf6873"
labels: {3}
logName: "projects/MYAPPNAME/logs/run.googleapis.com%2Fstderr"
receiveTimestamp: "2024-09-25T14:08:44.418319648Z"
resource: {2}
spanId: "9273010944203965244"
textPayload: "Permission 'iam.serviceAccounts.signBlob' denied on resource (or it may not exist).; Please refer to https://firebase.google.com/docs/auth/admin/create-custom-tokens for more details on how to use and troubleshoot this feature."
timestamp: "2024-09-25T14:08:44.412005Z"
trace: "57be6ab1ccede7137ab99da15a2b120e"
}
Re-deploying my application fixes it, (literally nothing changes as I just re-run the last Github Action), and everything works once again upon completion.
Any ideas?
Edit 1
Adding the firebase.json
content
{
"hosting": {
"source": ".",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"frameworksBackend": {
"region": "europe-west1"
},
"rewrites": [
{
"source": "**",
"function": "THEAUTOMATEDFUNCTIONNAME"
}
]
},
"emulators": {
"auth": {
"port": 9099
},
"firestore": {
"port": 8080
},
"database": {
"port": 9000
},
"storage": {
"port": 9199
},
"ui": {
"enabled": true
},
"singleProjectMode": true
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"storage": {
"rules": "storage. Rules"
}
}