Firebase Cloud Function with Pub/Sub Trigger

384 views
Skip to first unread message

nAv

unread,
Apr 25, 2017, 10:22:49 AM4/25/17
to Firebase Google Group
Hello there,

As the subject suggests, I have a function using the:
 functions.pubsub.topic('my-topic').onPublish(event => {}) API

My function goes on to make a remote request, and does a bunch of work once that request is done. Seeing that the event is immediately returned (there's no "callback"), there's a bunch of funky stuff happening: I get the remaining log messages (after my remote request) 30-seconds+ after the initial event was handled. Any idea how to resolve this? The remote request shouldn't take more than 1s to return.

This issue doesn't happen with HTTP triggers where I can make sure to hit res.status(... after my work is complete.

Thanks

Conor Dockry

unread,
Apr 25, 2017, 11:25:29 PM4/25/17
to Firebase Google Group
Looks like your handler function needs to return Promise

onPublish(handler: (event: Event<Message>) => PromiseLike<any> | any): CloudFunction<Message>


nAv

unread,
Apr 26, 2017, 9:27:25 AM4/26/17
to Firebase Google Group
Perfect! Fixed the issue, thanks for that. Wish this was mentioned on the documentation

Kato Richardson

unread,
Apr 26, 2017, 3:35:48 PM4/26/17
to Firebase Google Group
There is a "send feedback" link on that docs page; I'd recommend using it : )

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/52231acc-a382-4155-a927-bdf50c2f28f2%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

nAv

unread,
Apr 26, 2017, 6:53:36 PM4/26/17
to Firebase Google Group
Already done 👍🏾
Thanks


On Thursday, April 27, 2017 at 1:05:48 AM UTC+5:30, Kato Richardson wrote:
There is a "send feedback" link on that docs page; I'd recommend using it : )

☼, Kato
On Wed, Apr 26, 2017 at 2:55 AM, nAv <pat...@gmail.com> wrote:
Perfect! Fixed the issue, thanks for that. Wish this was mentioned on the documentation


On Wednesday, April 26, 2017 at 8:55:29 AM UTC+5:30, Conor Dockry wrote:
Looks like your handler function needs to return Promise

onPublish(handler: (event: Event<Message>) => PromiseLike<any> | any): CloudFunction<Message>



On Tuesday, April 25, 2017 at 10:22:49 AM UTC-4, nAv wrote:
Hello there,

As the subject suggests, I have a function using the:
 functions.pubsub.topic('my-topic').onPublish(event => {}) API

My function goes on to make a remote request, and does a bunch of work once that request is done. Seeing that the event is immediately returned (there's no "callback"), there's a bunch of funky stuff happening: I get the remaining log messages (after my remote request) 30-seconds+ after the initial event was handled. Any idea how to resolve this? The remote request shouldn't take more than 1s to return.

This issue doesn't happen with HTTP triggers where I can make sure to hit res.status(... after my work is complete.

Thanks

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages