how do i terminate a firebase callable function that does not need to return anything?

Your function must return a promise that resolves when all the async work is complete. You can’t return early – you must wait for the completion, otherwise Cloud Functions might forcibly shut down the function, and it will never complete.

For callable functions in particular, you must also return a promise that resolves with the data to serialize to the client app. It’s better to be specific about this than try to serialize the result of some unknown promise results.

export const onCall_updateViewCount = functions.https.onCall((data, context) => {

  const { id } = data;

  return admin.firestore().collection(VIEWCOUNT).doc(VIEWCOUNT).update({
    [id]: admin.firestore.FieldValue.increment(1)
  .then(() => {
    return { result: "OK" };

Be sure to review the documentation for callable functions.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top