firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Version 11.10.0 no longer calls onFinalize background function

Open johnnyoshika opened this issue 3 years ago • 2 comments

[REQUIRED] Environment info

firebase-tools: 11.10.0 (also tested 11.12.0)

Platform: Windows

[REQUIRED] Test case

export const onFileFinalize = functions.storage
  .object()
  .onFinalize(async object => {
  
  console.log('Hello');
});

Then upload using the Web SDK's uploadBytesResumable().

[REQUIRED] Steps to reproduce

Start the emulator, upload file with uploadBytesResumable(), then observe that onFinalize() background function doesn't get triggered.

[REQUIRED] Expected behavior

Expect onFinalize() background function to get triggered. This worked properly in [email protected], so this is a regression that was introduced in version 11.10.0.

[REQUIRED] Actual behavior

Background function doesn't get triggered.

johnnyoshika avatar Sep 30 '22 15:09 johnnyoshika

I've seen something similar recently. There should be a log for the storage emulator - could you provide the output of that?

bkendall avatar Sep 30 '22 20:09 bkendall

@bkendall I can't find the storage emulator log. Can you point me in the right direction? I do see firebase-debug.log though.

Here's what I see printed in firebase-debug.log when I upload a file using [email protected]:

[debug] [2022-09-30T21:24:06.695Z] Sep. 30, 2022 2:24:06 P.M. io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Sep. 30, 2022 2:24:06 P.M. io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\r\nINFO: Detected non-HTTP/2 connection.\r\n"}}
[debug] [2022-09-30T21:24:07.997Z] >>> [apiv2][query] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast [none]
[debug] [2022-09-30T21:24:07.997Z] >>> [apiv2][body] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast {"eventId":"1664573047997","timestamp":"2022-09-30T21:24:07.997Z","eventType":"google.storage.object.finalize","resource":{"service":"storage.googleapis.com","name":"projects/_/buckets/demo-project.appspot.com/objects/courses/-seed-course/fileConversions/bu7A8ey-SpP4PUlb0A0mD.docx","type":"storage#object"},"data":{"kind":"storage#object","name":"courses/-seed-course/fileConversions/bu7A8ey-SpP4PUlb0A0mD.docx","bucket":"demo-project.appspot.com","generation":"1664573047992","metageneration":"1","contentType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","timeCreated":"2022-09-30T21:24:07.992Z","updated":"2022-09-30T21:24:07.992Z","storageClass":"STANDARD","size":"195177","md5Hash":"aVwAQ5wAI1M9zmIudZBQgQ==","etag":"30pujgOjbKuVeagkkTRGlj8Z2sg","metadata":{"uploaderId":"-seed-user-mod","spaceId":"-seed-space","originalFileName":"getmarked-practice-0 (1).docx","firebaseStorageDownloadTokens":"2825a78d-dd00-4c0e-8ac0-708c4c403413"},"crc32c":"BHaEaA==","timeStorageClassUpdated":"2022-09-30T21:24:07.992Z","id":"demo-project.appspot.com/courses/-seed-course/fileConversions/bu7A8ey-SpP4PUlb0A0mD.docx/1664573047992","selfLink":"http://localhost:9199/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2Fbu7A8ey-SpP4PUlb0A0mD.docx","mediaLink":"http://localhost:9199/download/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2Fbu7A8ey-SpP4PUlb0A0mD.docx?generation=1664573047992&alt=media"}}
[debug] [2022-09-30T21:24:07.999Z] [work-queue] {"queueLength":2,"workRunningCount":1}
[debug] [2022-09-30T21:24:08.000Z] <<< [apiv2][status] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast 200
[debug] [2022-09-30T21:24:08.000Z] <<< [apiv2][body] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast {"status":"multicast_acknowledged"}
[debug] [2022-09-30T21:24:08.000Z] >>> [apiv2][query] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast [none]
[debug] [2022-09-30T21:24:08.000Z] >>> [apiv2][body] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast {"specversion":"1","id":"69f74dc0-7068-4457-8f8f-a3ecb256794c","type":"google.cloud.storage.object.v1.finalized","source":"//storage.googleapis.com/projects/_/buckets/demo-project.appspot.com/objects/courses/-seed-course/fileConversions/bu7A8ey-SpP4PUlb0A0mD.docx","time":"2022-09-30T21:24:07.992Z","data":{"kind":"storage#object","name":"courses/-seed-course/fileConversions/bu7A8ey-SpP4PUlb0A0mD.docx","bucket":"demo-project.appspot.com","generation":"1664573047992","metageneration":"1","contentType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","timeCreated":"2022-09-30T21:24:07.992Z","updated":"2022-09-30T21:24:07.992Z","storageClass":"STANDARD","size":"195177","md5Hash":"aVwAQ5wAI1M9zmIudZBQgQ==","etag":"30pujgOjbKuVeagkkTRGlj8Z2sg","metadata":{"uploaderId":"-seed-user-mod","spaceId":"-seed-space","originalFileName":"getmarked-practice-0 (1).docx","firebaseStorageDownloadTokens":"2825a78d-dd00-4c0e-8ac0-708c4c403413"},"crc32c":"BHaEaA==","timeStorageClassUpdated":"2022-09-30T21:24:07.992Z","id":"demo-project.appspot.com/courses/-seed-course/fileConversions/bu7A8ey-SpP4PUlb0A0mD.docx/1664573047992","selfLink":"http://localhost:9199/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2Fbu7A8ey-SpP4PUlb0A0mD.docx","mediaLink":"http://localhost:9199/download/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2Fbu7A8ey-SpP4PUlb0A0mD.docx?generation=1664573047992&alt=media"}}
[debug] [2022-09-30T21:24:08.001Z] <<< [apiv2][status] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast 200
[debug] [2022-09-30T21:24:08.001Z] <<< [apiv2][body] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast {"status":"multicast_acknowledged"}

Compared to this with [email protected]:

[debug] [2022-09-30T21:28:15.559Z] >>> [apiv2][query] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast [none]
[debug] [2022-09-30T21:28:15.559Z] >>> [apiv2][body] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast {"eventId":"1664573295559","timestamp":"2022-09-30T21:28:15.559Z","eventType":"google.storage.object.finalize","resource":{"service":"storage.googleapis.com","name":"projects/_/buckets/demo-project.appspot.com/objects/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx","type":"storage#object"},"data":{"kind":"storage#object","name":"courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx","bucket":"demo-project.appspot.com","generation":"1664573295554","metageneration":"1","contentType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","timeCreated":"2022-09-30T21:28:15.554Z","updated":"2022-09-30T21:28:15.554Z","storageClass":"STANDARD","size":"195177","md5Hash":"aVwAQ5wAI1M9zmIudZBQgQ==","etag":"Y+gzhhwzkzeaZlw/9s5q85NmBsU","metadata":{"uploaderId":"-seed-user-mod","spaceId":"-seed-space","originalFileName":"getmarked-practice-0 (1).docx","firebaseStorageDownloadTokens":"e3589c72-5f63-4b66-9431-6a910378fc6f"},"crc32c":"BHaEaA==","timeStorageClassUpdated":"2022-09-30T21:28:15.554Z","id":"demo-project.appspot.com/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx/1664573295554","selfLink":"http://localhost:9199/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx","mediaLink":"http://localhost:9199/download/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx?generation=1664573295554&alt=media"}}
[debug] [2022-09-30T21:28:15.561Z] [work-queue] {"queueLength":1,"workRunningCount":0}
[debug] [2022-09-30T21:28:15.561Z] [work-queue] {"queueLength":0,"workRunningCount":1}
[debug] [2022-09-30T21:28:15.561Z] Accepted multicast request POST /functions/projects/demo-project/trigger_multicast --> us-central1-onFileConversionFinalize-0 {"metadata":{"emulator":{"name":"functions"},"message":"Accepted multicast request POST /functions/projects/demo-project/trigger_multicast --> us-central1-onFileConversionFinalize-0"}}
[debug] [2022-09-30T21:28:15.562Z] [worker-pool] submitWork(triggerId=us-central1-onFileConversionFinalize) {"metadata":{"emulator":{"name":"functions"},"message":"[worker-pool] submitWork(triggerId=us-central1-onFileConversionFinalize)"}}
[debug] [2022-09-30T21:28:15.562Z] [worker-~shared~-b6838394-7331-4d28-bb47-4337af49f989]: BUSY {"metadata":{"emulator":{"name":"functions"},"message":"[worker-~shared~-b6838394-7331-4d28-bb47-4337af49f989]: BUSY"}}
[debug] [2022-09-30T21:28:15.563Z] <<< [apiv2][status] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast 200
[debug] [2022-09-30T21:28:15.563Z] <<< [apiv2][body] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast {"status":"multicast_acknowledged"}
[debug] [2022-09-30T21:28:15.563Z] >>> [apiv2][query] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast [none]
[debug] [2022-09-30T21:28:15.563Z] >>> [apiv2][body] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast {"specversion":"1","id":"41ecb0dd-77f8-4061-a259-2053125e1f4d","type":"google.cloud.storage.object.v1.finalized","source":"//storage.googleapis.com/projects/_/buckets/demo-project.appspot.com/objects/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx","time":"2022-09-30T21:28:15.554Z","data":{"kind":"storage#object","name":"courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx","bucket":"demo-project.appspot.com","generation":"1664573295554","metageneration":"1","contentType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","timeCreated":"2022-09-30T21:28:15.554Z","updated":"2022-09-30T21:28:15.554Z","storageClass":"STANDARD","size":"195177","md5Hash":"aVwAQ5wAI1M9zmIudZBQgQ==","etag":"Y+gzhhwzkzeaZlw/9s5q85NmBsU","metadata":{"uploaderId":"-seed-user-mod","spaceId":"-seed-space","originalFileName":"getmarked-practice-0 (1).docx","firebaseStorageDownloadTokens":"e3589c72-5f63-4b66-9431-6a910378fc6f"},"crc32c":"BHaEaA==","timeStorageClassUpdated":"2022-09-30T21:28:15.554Z","id":"demo-project.appspot.com/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx/1664573295554","selfLink":"http://localhost:9199/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx","mediaLink":"http://localhost:9199/download/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx?generation=1664573295554&alt=media"}}
[debug] [2022-09-30T21:28:15.563Z] [runtime-status] [3380] Beginning invocation function onFileConversionFinalize! {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [3380] Beginning invocation function onFileConversionFinalize!"}}
[info] i  functions: Beginning execution of "onFileConversionFinalize" {"metadata":{"emulator":{"name":"functions"},"message":"Beginning execution of \"onFileConversionFinalize\""}}
[debug] [2022-09-30T21:28:15.564Z] [runtime-status] [3380] Running onFileConversionFinalize in signature event {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [3380] Running onFileConversionFinalize in signature event"}}
[debug] [2022-09-30T21:28:15.564Z] [runtime-status] [3380] ProcessBackground {"eventId":"1664573295559","timestamp":"2022-09-30T21:28:15.559Z","eventType":"google.storage.object.finalize","resource":{"service":"storage.googleapis.com","name":"projects/_/buckets/demo-project.appspot.com/objects/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx","type":"storage#object"},"data":{"kind":"storage#object","name":"courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx","bucket":"demo-project.appspot.com","generation":"1664573295554","metageneration":"1","contentType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","timeCreated":"2022-09-30T21:28:15.554Z","updated":"2022-09-30T21:28:15.554Z","storageClass":"STANDARD","size":"195177","md5Hash":"aVwAQ5wAI1M9zmIudZBQgQ==","etag":"Y+gzhhwzkzeaZlw/9s5q85NmBsU","metadata":{"uploaderId":"-seed-user-mod","spaceId":"-seed-space","originalFileName":"getmarked-practice-0 (1).docx","firebaseStorageDownloadTokens":"e3589c72-5f63-4b66-9431-6a910378fc6f"},"crc32c":"BHaEaA==","timeStorageClassUpdated":"2022-09-30T21:28:15.554Z","id":"demo-project.appspot.com/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx/1664573295554","selfLink":"http://localhost:9199/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx","mediaLink":"http://localhost:9199/download/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx?generation=1664573295554&alt=media"}} {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [3380] ProcessBackground {\"eventId\":\"1664573295559\",\"timestamp\":\"2022-09-30T21:28:15.559Z\",\"eventType\":\"google.storage.object.finalize\",\"resource\":{\"service\":\"storage.googleapis.com\",\"name\":\"projects/_/buckets/demo-project.appspot.com/objects/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx\",\"type\":\"storage#object\"},\"data\":{\"kind\":\"storage#object\",\"name\":\"courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx\",\"bucket\":\"demo-project.appspot.com\",\"generation\":\"1664573295554\",\"metageneration\":\"1\",\"contentType\":\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\"timeCreated\":\"2022-09-30T21:28:15.554Z\",\"updated\":\"2022-09-30T21:28:15.554Z\",\"storageClass\":\"STANDARD\",\"size\":\"195177\",\"md5Hash\":\"aVwAQ5wAI1M9zmIudZBQgQ==\",\"etag\":\"Y+gzhhwzkzeaZlw/9s5q85NmBsU\",\"metadata\":{\"uploaderId\":\"-seed-user-mod\",\"spaceId\":\"-seed-space\",\"originalFileName\":\"getmarked-practice-0 (1).docx\",\"firebaseStorageDownloadTokens\":\"e3589c72-5f63-4b66-9431-6a910378fc6f\"},\"crc32c\":\"BHaEaA==\",\"timeStorageClassUpdated\":\"2022-09-30T21:28:15.554Z\",\"id\":\"demo-project.appspot.com/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx/1664573295554\",\"selfLink\":\"http://localhost:9199/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx\",\"mediaLink\":\"http://localhost:9199/download/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx?generation=1664573295554&alt=media\"}}"}}
[debug] [2022-09-30T21:28:15.564Z] [runtime-status] [3380] RunBackground {"data":{"kind":"storage#object","name":"courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx","bucket":"demo-project.appspot.com","generation":"1664573295554","metageneration":"1","contentType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","timeCreated":"2022-09-30T21:28:15.554Z","updated":"2022-09-30T21:28:15.554Z","storageClass":"STANDARD","size":"195177","md5Hash":"aVwAQ5wAI1M9zmIudZBQgQ==","etag":"Y+gzhhwzkzeaZlw/9s5q85NmBsU","metadata":{"uploaderId":"-seed-user-mod","spaceId":"-seed-space","originalFileName":"getmarked-practice-0 (1).docx","firebaseStorageDownloadTokens":"e3589c72-5f63-4b66-9431-6a910378fc6f"},"crc32c":"BHaEaA==","timeStorageClassUpdated":"2022-09-30T21:28:15.554Z","id":"demo-project.appspot.com/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx/1664573295554","selfLink":"http://localhost:9199/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx","mediaLink":"http://localhost:9199/download/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx?generation=1664573295554&alt=media"},"context":{"eventId":"1664573295559","timestamp":"2022-09-30T21:28:15.559Z","eventType":"google.storage.object.finalize","resource":{"service":"storage.googleapis.com","name":"projects/_/buckets/demo-project.appspot.com/objects/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx","type":"storage#object"}}} {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [3380] RunBackground {\"data\":{\"kind\":\"storage#object\",\"name\":\"courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx\",\"bucket\":\"demo-project.appspot.com\",\"generation\":\"1664573295554\",\"metageneration\":\"1\",\"contentType\":\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\"timeCreated\":\"2022-09-30T21:28:15.554Z\",\"updated\":\"2022-09-30T21:28:15.554Z\",\"storageClass\":\"STANDARD\",\"size\":\"195177\",\"md5Hash\":\"aVwAQ5wAI1M9zmIudZBQgQ==\",\"etag\":\"Y+gzhhwzkzeaZlw/9s5q85NmBsU\",\"metadata\":{\"uploaderId\":\"-seed-user-mod\",\"spaceId\":\"-seed-space\",\"originalFileName\":\"getmarked-practice-0 (1).docx\",\"firebaseStorageDownloadTokens\":\"e3589c72-5f63-4b66-9431-6a910378fc6f\"},\"crc32c\":\"BHaEaA==\",\"timeStorageClassUpdated\":\"2022-09-30T21:28:15.554Z\",\"id\":\"demo-project.appspot.com/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx/1664573295554\",\"selfLink\":\"http://localhost:9199/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx\",\"mediaLink\":\"http://localhost:9199/download/storage/v1/b/demo-project.appspot.com/o/courses%2F-seed-course%2FfileConversions%2FhZWrLnsjXLrBJgoECvk9b.docx?generation=1664573295554&alt=media\"},\"context\":{\"eventId\":\"1664573295559\",\"timestamp\":\"2022-09-30T21:28:15.559Z\",\"eventType\":\"google.storage.object.finalize\",\"resource\":{\"service\":\"storage.googleapis.com\",\"name\":\"projects/_/buckets/demo-project.appspot.com/objects/courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx\",\"type\":\"storage#object\"}}}"}}
[debug] [2022-09-30T21:28:15.565Z] <<< [apiv2][status] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast 200
[debug] [2022-09-30T21:28:15.565Z] <<< [apiv2][body] POST http://localhost:5001/functions/projects/demo-project/trigger_multicast {"status":"multicast_acknowledged"}
[debug] [2022-09-30T21:28:17.447Z] [work-queue] {"queueLength":1,"workRunningCount":1}
[debug] [2022-09-30T21:28:17.447Z] [runtime-status] [3380] Ephemeral server survived. {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [3380] Ephemeral server survived."}}
[info] i  functions: Finished "onFileConversionFinalize" in ~1s {"metadata":{"emulator":{"name":"functions"},"message":"Finished \"onFileConversionFinalize\" in ~1s"}}
[debug] [2022-09-30T21:28:17.448Z] [worker-~shared~-b6838394-7331-4d28-bb47-4337af49f989]: IDLE {"metadata":{"emulator":{"name":"functions"},"message":"[worker-~shared~-b6838394-7331-4d28-bb47-4337af49f989]: IDLE"}}
[debug] [2022-09-30T21:28:17.448Z] [work-queue] {"queueLength":1,"workRunningCount":0}
[debug] [2022-09-30T21:28:17.448Z] [work-queue] {"queueLength":0,"workRunningCount":1}
[debug] [2022-09-30T21:28:17.448Z] Accepted request POST /functions/projects/demo-project/triggers/us-central1-onTaskWrite-0 --> us-central1-onTaskWrite-0 {"metadata":{"emulator":{"name":"functions"},"message":"Accepted request POST /functions/projects/demo-project/triggers/us-central1-onTaskWrite-0 --> us-central1-onTaskWrite-0"}}
[debug] [2022-09-30T21:28:17.448Z] [worker-pool] submitWork(triggerId=us-central1-onTaskWrite) {"metadata":{"emulator":{"name":"functions"},"message":"[worker-pool] submitWork(triggerId=us-central1-onTaskWrite)"}}
[debug] [2022-09-30T21:28:17.448Z] [worker-~shared~-b6838394-7331-4d28-bb47-4337af49f989]: BUSY {"metadata":{"emulator":{"name":"functions"},"message":"[worker-~shared~-b6838394-7331-4d28-bb47-4337af49f989]: BUSY"}}
[debug] [2022-09-30T21:28:17.466Z] [runtime-status] [3380] Beginning invocation function onTaskWrite! {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [3380] Beginning invocation function onTaskWrite!"}}
[info] i  functions: Beginning execution of "onTaskWrite" {"metadata":{"emulator":{"name":"functions"},"message":"Beginning execution of \"onTaskWrite\""}}
[debug] [2022-09-30T21:28:17.467Z] [runtime-status] [3380] Running onTaskWrite in signature event {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [3380] Running onTaskWrite in signature event"}}
[debug] [2022-09-30T21:28:17.467Z] [runtime-status] [3380] ProcessBackground {"data":{"value":{"name":"projects/demo-project/databases/(default)/documents/courses/-seed-course/tasks/5rjpymkG8amgi7ZU26x3Y","fields":{"data":{"mapValue":{"fields":{"originalFileName":{"stringValue":"getmarked-practice-0 (1).docx"},"uploaderId":{"stringValue":"-seed-user-mod"},"resultEndpoint":{"stringValue":"https://digitaliser.getmarked.ai/api/v1.0/job/23111/"},"objectName":{"stringValue":"courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx"}}}},"warnings":{"arrayValue":{}},"name":{"stringValue":"File Convert"},"progress":{"integerValue":"0"},"onDoneNavigateTo":{"nullValue":null},"id":{"stringValue":"5rjpymkG8amgi7ZU26x3Y"},"type":{"stringValue":"FileConvert"},"errors":{"arrayValue":{}},"status":{"stringValue":"Queued"},"createdAt":{"timestampValue":"2022-09-30T21:28:17.445Z"}},"createTime":"2022-09-30T21:28:17.445964Z","updateTime":"2022-09-30T21:28:17.445964Z"},"updateMask":{}},"context":{"eventId":"a8306386-88bd-4b28-a193-d124d33882f8","timestamp":"2022-09-30T21:28:17.445Z","eventType":"providers/cloud.firestore/eventTypes/document.write","resource":{"name":"projects/demo-project/databases/(default)/documents/courses/-seed-course/tasks/5rjpymkG8amgi7ZU26x3Y","service":"firestore.googleapis.com"}}} {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [3380] ProcessBackground {\"data\":{\"value\":{\"name\":\"projects/demo-project/databases/(default)/documents/courses/-seed-course/tasks/5rjpymkG8amgi7ZU26x3Y\",\"fields\":{\"data\":{\"mapValue\":{\"fields\":{\"originalFileName\":{\"stringValue\":\"getmarked-practice-0 (1).docx\"},\"uploaderId\":{\"stringValue\":\"-seed-user-mod\"},\"resultEndpoint\":{\"stringValue\":\"https://digitaliser.getmarked.ai/api/v1.0/job/23111/\"},\"objectName\":{\"stringValue\":\"courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx\"}}}},\"warnings\":{\"arrayValue\":{}},\"name\":{\"stringValue\":\"File Convert\"},\"progress\":{\"integerValue\":\"0\"},\"onDoneNavigateTo\":{\"nullValue\":null},\"id\":{\"stringValue\":\"5rjpymkG8amgi7ZU26x3Y\"},\"type\":{\"stringValue\":\"FileConvert\"},\"errors\":{\"arrayValue\":{}},\"status\":{\"stringValue\":\"Queued\"},\"createdAt\":{\"timestampValue\":\"2022-09-30T21:28:17.445Z\"}},\"createTime\":\"2022-09-30T21:28:17.445964Z\",\"updateTime\":\"2022-09-30T21:28:17.445964Z\"},\"updateMask\":{}},\"context\":{\"eventId\":\"a8306386-88bd-4b28-a193-d124d33882f8\",\"timestamp\":\"2022-09-30T21:28:17.445Z\",\"eventType\":\"providers/cloud.firestore/eventTypes/document.write\",\"resource\":{\"name\":\"projects/demo-project/databases/(default)/documents/courses/-seed-course/tasks/5rjpymkG8amgi7ZU26x3Y\",\"service\":\"firestore.googleapis.com\"}}}"}}
[debug] [2022-09-30T21:28:17.467Z] [runtime-status] [3380] ProcessBackground: lifting resource.name from resource {"name":"projects/demo-project/databases/(default)/documents/courses/-seed-course/tasks/5rjpymkG8amgi7ZU26x3Y","service":"firestore.googleapis.com"} {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [3380] ProcessBackground: lifting resource.name from resource {\"name\":\"projects/demo-project/databases/(default)/documents/courses/-seed-course/tasks/5rjpymkG8amgi7ZU26x3Y\",\"service\":\"firestore.googleapis.com\"}"}}
[debug] [2022-09-30T21:28:17.467Z] [runtime-status] [3380] RunBackground {"data":{"value":{"name":"projects/demo-project/databases/(default)/documents/courses/-seed-course/tasks/5rjpymkG8amgi7ZU26x3Y","fields":{"data":{"mapValue":{"fields":{"originalFileName":{"stringValue":"getmarked-practice-0 (1).docx"},"uploaderId":{"stringValue":"-seed-user-mod"},"resultEndpoint":{"stringValue":"https://digitaliser.getmarked.ai/api/v1.0/job/23111/"},"objectName":{"stringValue":"courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx"}}}},"warnings":{"arrayValue":{}},"name":{"stringValue":"File Convert"},"progress":{"integerValue":"0"},"onDoneNavigateTo":{"nullValue":null},"id":{"stringValue":"5rjpymkG8amgi7ZU26x3Y"},"type":{"stringValue":"FileConvert"},"errors":{"arrayValue":{}},"status":{"stringValue":"Queued"},"createdAt":{"timestampValue":"2022-09-30T21:28:17.445Z"}},"createTime":"2022-09-30T21:28:17.445964Z","updateTime":"2022-09-30T21:28:17.445964Z"},"updateMask":{}},"context":{"eventId":"a8306386-88bd-4b28-a193-d124d33882f8","timestamp":"2022-09-30T21:28:17.445Z","eventType":"providers/cloud.firestore/eventTypes/document.write","resource":"projects/demo-project/databases/(default)/documents/courses/-seed-course/tasks/5rjpymkG8amgi7ZU26x3Y"}} {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [3380] RunBackground {\"data\":{\"value\":{\"name\":\"projects/demo-project/databases/(default)/documents/courses/-seed-course/tasks/5rjpymkG8amgi7ZU26x3Y\",\"fields\":{\"data\":{\"mapValue\":{\"fields\":{\"originalFileName\":{\"stringValue\":\"getmarked-practice-0 (1).docx\"},\"uploaderId\":{\"stringValue\":\"-seed-user-mod\"},\"resultEndpoint\":{\"stringValue\":\"https://digitaliser.getmarked.ai/api/v1.0/job/23111/\"},\"objectName\":{\"stringValue\":\"courses/-seed-course/fileConversions/hZWrLnsjXLrBJgoECvk9b.docx\"}}}},\"warnings\":{\"arrayValue\":{}},\"name\":{\"stringValue\":\"File Convert\"},\"progress\":{\"integerValue\":\"0\"},\"onDoneNavigateTo\":{\"nullValue\":null},\"id\":{\"stringValue\":\"5rjpymkG8amgi7ZU26x3Y\"},\"type\":{\"stringValue\":\"FileConvert\"},\"errors\":{\"arrayValue\":{}},\"status\":{\"stringValue\":\"Queued\"},\"createdAt\":{\"timestampValue\":\"2022-09-30T21:28:17.445Z\"}},\"createTime\":\"2022-09-30T21:28:17.445964Z\",\"updateTime\":\"2022-09-30T21:28:17.445964Z\"},\"updateMask\":{}},\"context\":{\"eventId\":\"a8306386-88bd-4b28-a193-d124d33882f8\",\"timestamp\":\"2022-09-30T21:28:17.445Z\",\"eventType\":\"providers/cloud.firestore/eventTypes/document.write\",\"resource\":\"projects/demo-project/databases/(default)/documents/courses/-seed-course/tasks/5rjpymkG8amgi7ZU26x3Y\"}}"}}

Note: my background function name is onFileConversionFinalize. You can see it being triggered in the second log but not the first.

johnnyoshika avatar Sep 30 '22 21:09 johnnyoshika

Do you run these with --inspect-functions ?

tomas-carv-com avatar Oct 22 '22 02:10 tomas-carv-com

@tomas-carv-com by default I do. Do you want me to try without?

johnnyoshika avatar Oct 22 '22 23:10 johnnyoshika

This problem continues to exist in 11.15.0 as well. Temporary fix: revert back to 11.9.0 with "npm i -g [email protected]"

chrisle avatar Oct 29 '22 16:10 chrisle

Yeah, I'm stuck on version 11.9.0 until this problem is fixed

johnnyoshika avatar Oct 29 '22 23:10 johnnyoshika

@colerogers, can you look into this since you know the storage functions emulator best?

@chrisle and @johnnyoshika is this happening to you in prod as well or just in the emulator?

inlined avatar Oct 31 '22 21:10 inlined

@inlined Only in the emulator when using [email protected]+

johnnyoshika avatar Nov 02 '22 16:11 johnnyoshika

I'll take a look into this. Also, we just released 11.16.0 yesterday which includes a fix to another emulator concurrency issue. Just to confirm, that version still doesn't trigger onFinalize functions, right?

colerogers avatar Nov 02 '22 20:11 colerogers

@colerogers , nope issue is still persistent. When emulators run with --inspect-functions authTrigger does not work

tomas-carv-com avatar Nov 02 '22 23:11 tomas-carv-com

Hey folks, so I built a small test app that uses uploadBytesResumable() and I'm able to get the function to trigger correctly by running the emulator normally. If I use --inspect-functions, then I'm able to get the same results as all of you. Just to isolate this problem, is there anyone in this thread that runs in to this issue without using --inspect-functions? Thanks

colerogers avatar Nov 03 '22 18:11 colerogers

We think we have a fix and are working on a patch.

If anyone has time to help - would love to have folks test out the dl-fn-emu-inspect-bug branch which contains our proposed fix on their workflow.

Steps for running a local version of the Firebase CLI is available at https://github.com/firebase/firebase-tools/blob/master/CONTRIBUTING.md#getting-started.

taeold avatar Nov 04 '22 17:11 taeold

@taeold Better late than never. I just tested firebase-tools from source with dl-fn-emu-inspect-bug branch and onFinalize was called properly with --inspect-functions enabled. I also checked out the commit tagged with v11.16.0 and ran the same test to ensure that onFinalize wasn't called, and that was the case. So I was able to reproduce the problem in tag v11.16.0 and confirm the fix in dl-fn-emu-inspect-bug, so I can confirm that your changes fixed the problem.

I see that version v11.16.1's been released which includes this fix, so I'll upgrade to that soon and close this issue once I confirm that the released version works as expected.

johnnyoshika avatar Nov 16 '22 17:11 johnnyoshika

Confirmed that everything's working in v11.16.1.

Thanks @taeold.

Closing!

johnnyoshika avatar Nov 16 '22 17:11 johnnyoshika

We have a regression. onFinalize background function no longer gets called in [email protected] when --inspect-functions is enabled.

@taeold Can you please investigate?

johnnyoshika avatar Jan 16 '23 20:01 johnnyoshika

Closing, as it seems to work fine on 11.20.0 now. Must have been a false positive. 🤷‍♀️

johnnyoshika avatar Jan 24 '23 20:01 johnnyoshika