0

I have an HTTPS callable function, that it does some logic, returns a result back, but in some cases I want to do some background work that might take a while, without waiting. At the moment it works, but I don't know if this is how it is supposed to be. Example:

exports.example = functions.https.onCall((data, context) => {
  // some logic //
  if(check(data,context))
    triggerSomeAsyncActions();

  return 200;
});

In the example above, it is important for me to return without waiting for triggerSomeAsyncActions().

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121
vagcore
  • 21
  • 6
  • See the duplicate answer. Also, note that a callable Cloud Function shall not be terminated by `return 200;`. See the doc: https://firebase.google.com/docs/functions/callable#sending_back_the_result – Renaud Tarnec Nov 24 '19 at 19:24
  • What do you mean it shall not be terminated by ```return 200;``` ? – vagcore Nov 24 '19 at 19:28
  • I guess that by doing `return 200;` you try to send back a response to the user who has triggered the Cloud Function. Sending back a response to the end-user in the framework of a Callable Cloud Function will **also terminate it**. However, doing `return 200` it is not the way to send back a response to the user. I should have written my comment as "In a callable Cloud Function you should not send the response to the user by doing `return 200;`". – Renaud Tarnec Nov 24 '19 at 19:31
  • Well, in a callable function, anything can be returned and that is the response. Thanks also for letting me know about the other post! – vagcore Nov 24 '19 at 20:05

0 Answers0