error firebase functions [Promises must be handled appropriately] on deploy












0















I was written a code previous week and it deploys without any error on firebase server. but now I cannot deploy it again on another account in orders to I don't change my code!



one of my friends tell me this in about new update of firebase but I don't find any solution for this!



it shows these errors



Promises must be handled appropriately


and



block is empty


the first error pointed to my first line and the second one pointed to end 'catch' block :



import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();

// export const helloWorld = functions.https.onRequest((request, response) => {
// console.log("sadegh");
// response.send("Hello from Firebase1!");
// });
//
export const sendChatNotification = functions
.firestore.document('rooms/{roomId}/messages/{messageId}')
.onCreate((snap, context) => {



const roomId = context.params.roomId;
const messageId = context.params.messageId;

const newValue = snap.data();

const receiverId = newValue.receiverId;
const text = newValue.text;
const type = newValue.type;
const senderName = newValue.senderName;


var p = admin.firestore().collection("users").doc(receiverId).get();
p.then(snapshot2 => {
const data2 = snapshot2.data();
const firebaseNotificationToken = data2.firebaseNotificationToken;
// const name = data2.name;

if (type == 'voiceCall' || type == 'videoCall' || type == 'hangUp') {


const channelId = newValue.channelId;
const senderId = newValue.senderId;
const status = newValue.status;

console.log("type: " + type + " /status: " + status)

let message = {
data: {
type: type,
senderId: senderId,
senderName: senderName,
receiverId: receiverId,
status: status,
channelId: channelId,
roomId: roomId
},
token: firebaseNotificationToken
};

sendMessage(message)


if (status == "canceled") {
let message1 = {
notification: {
title: '☎ Missed voice call ',
body: senderName
},
token: firebaseNotificationToken
};
sendMessage(message1)
} else if ((type == 'voiceCall' || type == 'videoCall') && status = '') {
let message1 = {
notification: {
title: '☎ ' + senderName + ' is calling you',
body: 'tap to answer...'
},
token: firebaseNotificationToken
};
sendMessage(message1)
}


} else {
let message = {
notification: {
title: '📃 ' + senderName,
body: text
},
token: firebaseNotificationToken
};


sendMessage(message)

}


return "";
}).catch((e) => {
console.log('error: ' + e);
return null;
});


// return "";
// }).catch(e=>{console.log('error: '+e)});


return "sadegh";
});

function sendMessage(message) {
admin.messaging().send(message)
.then((response) => {
// Response is a message ID string.
console.log('Successfully sent message:', response);
})
.catch((error) => {
console.log('Error sending message:', error);
});
}









share|improve this question

























  • Could you include in your question the full code of your Cloud Function? Most probably your problem comes form the fact that, among others, you don't return the promise returned by admin.firestore().collection("users").doc(receiverId).get()but we need the full (i.e. entire) code to confirm this assumption.

    – Renaud Tarnec
    Jan 19 at 10:24













  • @RenaudTarnec full code added. thanks for review

    – Sadegh
    Jan 20 at 8:20











  • Thanks for the addition. To be frank, your code is a bit messy and it is not really easy to understand it without dedicating a long time... However, here is below in my answer a piece of code that should work and that cover one case of your Business Logic. If you modify your code on the base on this first example, I'll will be happy to look at it again.

    – Renaud Tarnec
    Jan 20 at 11:33
















0















I was written a code previous week and it deploys without any error on firebase server. but now I cannot deploy it again on another account in orders to I don't change my code!



one of my friends tell me this in about new update of firebase but I don't find any solution for this!



it shows these errors



Promises must be handled appropriately


and



block is empty


the first error pointed to my first line and the second one pointed to end 'catch' block :



import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();

// export const helloWorld = functions.https.onRequest((request, response) => {
// console.log("sadegh");
// response.send("Hello from Firebase1!");
// });
//
export const sendChatNotification = functions
.firestore.document('rooms/{roomId}/messages/{messageId}')
.onCreate((snap, context) => {



const roomId = context.params.roomId;
const messageId = context.params.messageId;

const newValue = snap.data();

const receiverId = newValue.receiverId;
const text = newValue.text;
const type = newValue.type;
const senderName = newValue.senderName;


var p = admin.firestore().collection("users").doc(receiverId).get();
p.then(snapshot2 => {
const data2 = snapshot2.data();
const firebaseNotificationToken = data2.firebaseNotificationToken;
// const name = data2.name;

if (type == 'voiceCall' || type == 'videoCall' || type == 'hangUp') {


const channelId = newValue.channelId;
const senderId = newValue.senderId;
const status = newValue.status;

console.log("type: " + type + " /status: " + status)

let message = {
data: {
type: type,
senderId: senderId,
senderName: senderName,
receiverId: receiverId,
status: status,
channelId: channelId,
roomId: roomId
},
token: firebaseNotificationToken
};

sendMessage(message)


if (status == "canceled") {
let message1 = {
notification: {
title: '☎ Missed voice call ',
body: senderName
},
token: firebaseNotificationToken
};
sendMessage(message1)
} else if ((type == 'voiceCall' || type == 'videoCall') && status = '') {
let message1 = {
notification: {
title: '☎ ' + senderName + ' is calling you',
body: 'tap to answer...'
},
token: firebaseNotificationToken
};
sendMessage(message1)
}


} else {
let message = {
notification: {
title: '📃 ' + senderName,
body: text
},
token: firebaseNotificationToken
};


sendMessage(message)

}


return "";
}).catch((e) => {
console.log('error: ' + e);
return null;
});


// return "";
// }).catch(e=>{console.log('error: '+e)});


return "sadegh";
});

function sendMessage(message) {
admin.messaging().send(message)
.then((response) => {
// Response is a message ID string.
console.log('Successfully sent message:', response);
})
.catch((error) => {
console.log('Error sending message:', error);
});
}









share|improve this question

























  • Could you include in your question the full code of your Cloud Function? Most probably your problem comes form the fact that, among others, you don't return the promise returned by admin.firestore().collection("users").doc(receiverId).get()but we need the full (i.e. entire) code to confirm this assumption.

    – Renaud Tarnec
    Jan 19 at 10:24













  • @RenaudTarnec full code added. thanks for review

    – Sadegh
    Jan 20 at 8:20











  • Thanks for the addition. To be frank, your code is a bit messy and it is not really easy to understand it without dedicating a long time... However, here is below in my answer a piece of code that should work and that cover one case of your Business Logic. If you modify your code on the base on this first example, I'll will be happy to look at it again.

    – Renaud Tarnec
    Jan 20 at 11:33














0












0








0








I was written a code previous week and it deploys without any error on firebase server. but now I cannot deploy it again on another account in orders to I don't change my code!



one of my friends tell me this in about new update of firebase but I don't find any solution for this!



it shows these errors



Promises must be handled appropriately


and



block is empty


the first error pointed to my first line and the second one pointed to end 'catch' block :



import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();

// export const helloWorld = functions.https.onRequest((request, response) => {
// console.log("sadegh");
// response.send("Hello from Firebase1!");
// });
//
export const sendChatNotification = functions
.firestore.document('rooms/{roomId}/messages/{messageId}')
.onCreate((snap, context) => {



const roomId = context.params.roomId;
const messageId = context.params.messageId;

const newValue = snap.data();

const receiverId = newValue.receiverId;
const text = newValue.text;
const type = newValue.type;
const senderName = newValue.senderName;


var p = admin.firestore().collection("users").doc(receiverId).get();
p.then(snapshot2 => {
const data2 = snapshot2.data();
const firebaseNotificationToken = data2.firebaseNotificationToken;
// const name = data2.name;

if (type == 'voiceCall' || type == 'videoCall' || type == 'hangUp') {


const channelId = newValue.channelId;
const senderId = newValue.senderId;
const status = newValue.status;

console.log("type: " + type + " /status: " + status)

let message = {
data: {
type: type,
senderId: senderId,
senderName: senderName,
receiverId: receiverId,
status: status,
channelId: channelId,
roomId: roomId
},
token: firebaseNotificationToken
};

sendMessage(message)


if (status == "canceled") {
let message1 = {
notification: {
title: '☎ Missed voice call ',
body: senderName
},
token: firebaseNotificationToken
};
sendMessage(message1)
} else if ((type == 'voiceCall' || type == 'videoCall') && status = '') {
let message1 = {
notification: {
title: '☎ ' + senderName + ' is calling you',
body: 'tap to answer...'
},
token: firebaseNotificationToken
};
sendMessage(message1)
}


} else {
let message = {
notification: {
title: '📃 ' + senderName,
body: text
},
token: firebaseNotificationToken
};


sendMessage(message)

}


return "";
}).catch((e) => {
console.log('error: ' + e);
return null;
});


// return "";
// }).catch(e=>{console.log('error: '+e)});


return "sadegh";
});

function sendMessage(message) {
admin.messaging().send(message)
.then((response) => {
// Response is a message ID string.
console.log('Successfully sent message:', response);
})
.catch((error) => {
console.log('Error sending message:', error);
});
}









share|improve this question
















I was written a code previous week and it deploys without any error on firebase server. but now I cannot deploy it again on another account in orders to I don't change my code!



one of my friends tell me this in about new update of firebase but I don't find any solution for this!



it shows these errors



Promises must be handled appropriately


and



block is empty


the first error pointed to my first line and the second one pointed to end 'catch' block :



import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();

// export const helloWorld = functions.https.onRequest((request, response) => {
// console.log("sadegh");
// response.send("Hello from Firebase1!");
// });
//
export const sendChatNotification = functions
.firestore.document('rooms/{roomId}/messages/{messageId}')
.onCreate((snap, context) => {



const roomId = context.params.roomId;
const messageId = context.params.messageId;

const newValue = snap.data();

const receiverId = newValue.receiverId;
const text = newValue.text;
const type = newValue.type;
const senderName = newValue.senderName;


var p = admin.firestore().collection("users").doc(receiverId).get();
p.then(snapshot2 => {
const data2 = snapshot2.data();
const firebaseNotificationToken = data2.firebaseNotificationToken;
// const name = data2.name;

if (type == 'voiceCall' || type == 'videoCall' || type == 'hangUp') {


const channelId = newValue.channelId;
const senderId = newValue.senderId;
const status = newValue.status;

console.log("type: " + type + " /status: " + status)

let message = {
data: {
type: type,
senderId: senderId,
senderName: senderName,
receiverId: receiverId,
status: status,
channelId: channelId,
roomId: roomId
},
token: firebaseNotificationToken
};

sendMessage(message)


if (status == "canceled") {
let message1 = {
notification: {
title: '☎ Missed voice call ',
body: senderName
},
token: firebaseNotificationToken
};
sendMessage(message1)
} else if ((type == 'voiceCall' || type == 'videoCall') && status = '') {
let message1 = {
notification: {
title: '☎ ' + senderName + ' is calling you',
body: 'tap to answer...'
},
token: firebaseNotificationToken
};
sendMessage(message1)
}


} else {
let message = {
notification: {
title: '📃 ' + senderName,
body: text
},
token: firebaseNotificationToken
};


sendMessage(message)

}


return "";
}).catch((e) => {
console.log('error: ' + e);
return null;
});


// return "";
// }).catch(e=>{console.log('error: '+e)});


return "sadegh";
});

function sendMessage(message) {
admin.messaging().send(message)
.then((response) => {
// Response is a message ID string.
console.log('Successfully sent message:', response);
})
.catch((error) => {
console.log('Error sending message:', error);
});
}






javascript firebase google-cloud-firestore google-cloud-functions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 20 at 8:19







Sadegh

















asked Jan 19 at 6:45









SadeghSadegh

4001218




4001218













  • Could you include in your question the full code of your Cloud Function? Most probably your problem comes form the fact that, among others, you don't return the promise returned by admin.firestore().collection("users").doc(receiverId).get()but we need the full (i.e. entire) code to confirm this assumption.

    – Renaud Tarnec
    Jan 19 at 10:24













  • @RenaudTarnec full code added. thanks for review

    – Sadegh
    Jan 20 at 8:20











  • Thanks for the addition. To be frank, your code is a bit messy and it is not really easy to understand it without dedicating a long time... However, here is below in my answer a piece of code that should work and that cover one case of your Business Logic. If you modify your code on the base on this first example, I'll will be happy to look at it again.

    – Renaud Tarnec
    Jan 20 at 11:33



















  • Could you include in your question the full code of your Cloud Function? Most probably your problem comes form the fact that, among others, you don't return the promise returned by admin.firestore().collection("users").doc(receiverId).get()but we need the full (i.e. entire) code to confirm this assumption.

    – Renaud Tarnec
    Jan 19 at 10:24













  • @RenaudTarnec full code added. thanks for review

    – Sadegh
    Jan 20 at 8:20











  • Thanks for the addition. To be frank, your code is a bit messy and it is not really easy to understand it without dedicating a long time... However, here is below in my answer a piece of code that should work and that cover one case of your Business Logic. If you modify your code on the base on this first example, I'll will be happy to look at it again.

    – Renaud Tarnec
    Jan 20 at 11:33

















Could you include in your question the full code of your Cloud Function? Most probably your problem comes form the fact that, among others, you don't return the promise returned by admin.firestore().collection("users").doc(receiverId).get()but we need the full (i.e. entire) code to confirm this assumption.

– Renaud Tarnec
Jan 19 at 10:24







Could you include in your question the full code of your Cloud Function? Most probably your problem comes form the fact that, among others, you don't return the promise returned by admin.firestore().collection("users").doc(receiverId).get()but we need the full (i.e. entire) code to confirm this assumption.

– Renaud Tarnec
Jan 19 at 10:24















@RenaudTarnec full code added. thanks for review

– Sadegh
Jan 20 at 8:20





@RenaudTarnec full code added. thanks for review

– Sadegh
Jan 20 at 8:20













Thanks for the addition. To be frank, your code is a bit messy and it is not really easy to understand it without dedicating a long time... However, here is below in my answer a piece of code that should work and that cover one case of your Business Logic. If you modify your code on the base on this first example, I'll will be happy to look at it again.

– Renaud Tarnec
Jan 20 at 11:33





Thanks for the addition. To be frank, your code is a bit messy and it is not really easy to understand it without dedicating a long time... However, here is below in my answer a piece of code that should work and that cover one case of your Business Logic. If you modify your code on the base on this first example, I'll will be happy to look at it again.

– Renaud Tarnec
Jan 20 at 11:33












2 Answers
2






active

oldest

votes


















1














Your code is a bit messy and it is not really easy to understand it without dedicating a long time.



However, here is below a piece of code that should work and that cover one case of your Business Logic. Note how the promises returned by the asynchronous tasks are returned.



  export const sendChatNotification = functions.firestore
.document('rooms/{roomId}/messages/{messageId}')
.onCreate((snap, context) => {
const roomId = context.params.roomId;
const messageId = context.params.messageId;

const newValue = snap.data();

const receiverId = newValue.receiverId;
const text = newValue.text;
const type = newValue.type;
const senderName = newValue.senderName;

var p = admin
.firestore()
.collection('users')
.doc(receiverId)
.get();

return p.then(snapshot2 => { // <- HERE, the promise is returned
const data2 = snapshot2.data();
const firebaseNotificationToken = data2.firebaseNotificationToken;

if (type == 'voiceCall' || type == 'videoCall' || type == 'hangUp') {
const channelId = newValue.channelId;
const senderId = newValue.senderId;
const status = newValue.status;

console.log('type: ' + type + ' /status: ' + status);

let message = {
data: {
type: type,
senderId: senderId,
senderName: senderName,
receiverId: receiverId,
status: status,
channelId: channelId,
roomId: roomId
},
token: firebaseNotificationToken
};

return admin.messaging().send(message); // <- HERE, the promise is returned
}
});

});


I would suggest you watch the 3 videos about "JavaScript Promises" from the Firebase video series: https://firebase.google.com/docs/functions/video-series/






share|improve this answer































    0














    The problem is you commented the return in your catch block
    As your Firebase .get() function must return a promise, in your code, if it fails, it won't return a promise and it will hang there.



    either use return null or return something to be handled by the calling app






    share|improve this answer
























    • I add return null , return "" , return e ,... but not works!

      – Sadegh
      Jan 20 at 8:21











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264735%2ferror-firebase-functions-promises-must-be-handled-appropriately-on-deploy%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Your code is a bit messy and it is not really easy to understand it without dedicating a long time.



    However, here is below a piece of code that should work and that cover one case of your Business Logic. Note how the promises returned by the asynchronous tasks are returned.



      export const sendChatNotification = functions.firestore
    .document('rooms/{roomId}/messages/{messageId}')
    .onCreate((snap, context) => {
    const roomId = context.params.roomId;
    const messageId = context.params.messageId;

    const newValue = snap.data();

    const receiverId = newValue.receiverId;
    const text = newValue.text;
    const type = newValue.type;
    const senderName = newValue.senderName;

    var p = admin
    .firestore()
    .collection('users')
    .doc(receiverId)
    .get();

    return p.then(snapshot2 => { // <- HERE, the promise is returned
    const data2 = snapshot2.data();
    const firebaseNotificationToken = data2.firebaseNotificationToken;

    if (type == 'voiceCall' || type == 'videoCall' || type == 'hangUp') {
    const channelId = newValue.channelId;
    const senderId = newValue.senderId;
    const status = newValue.status;

    console.log('type: ' + type + ' /status: ' + status);

    let message = {
    data: {
    type: type,
    senderId: senderId,
    senderName: senderName,
    receiverId: receiverId,
    status: status,
    channelId: channelId,
    roomId: roomId
    },
    token: firebaseNotificationToken
    };

    return admin.messaging().send(message); // <- HERE, the promise is returned
    }
    });

    });


    I would suggest you watch the 3 videos about "JavaScript Promises" from the Firebase video series: https://firebase.google.com/docs/functions/video-series/






    share|improve this answer




























      1














      Your code is a bit messy and it is not really easy to understand it without dedicating a long time.



      However, here is below a piece of code that should work and that cover one case of your Business Logic. Note how the promises returned by the asynchronous tasks are returned.



        export const sendChatNotification = functions.firestore
      .document('rooms/{roomId}/messages/{messageId}')
      .onCreate((snap, context) => {
      const roomId = context.params.roomId;
      const messageId = context.params.messageId;

      const newValue = snap.data();

      const receiverId = newValue.receiverId;
      const text = newValue.text;
      const type = newValue.type;
      const senderName = newValue.senderName;

      var p = admin
      .firestore()
      .collection('users')
      .doc(receiverId)
      .get();

      return p.then(snapshot2 => { // <- HERE, the promise is returned
      const data2 = snapshot2.data();
      const firebaseNotificationToken = data2.firebaseNotificationToken;

      if (type == 'voiceCall' || type == 'videoCall' || type == 'hangUp') {
      const channelId = newValue.channelId;
      const senderId = newValue.senderId;
      const status = newValue.status;

      console.log('type: ' + type + ' /status: ' + status);

      let message = {
      data: {
      type: type,
      senderId: senderId,
      senderName: senderName,
      receiverId: receiverId,
      status: status,
      channelId: channelId,
      roomId: roomId
      },
      token: firebaseNotificationToken
      };

      return admin.messaging().send(message); // <- HERE, the promise is returned
      }
      });

      });


      I would suggest you watch the 3 videos about "JavaScript Promises" from the Firebase video series: https://firebase.google.com/docs/functions/video-series/






      share|improve this answer


























        1












        1








        1







        Your code is a bit messy and it is not really easy to understand it without dedicating a long time.



        However, here is below a piece of code that should work and that cover one case of your Business Logic. Note how the promises returned by the asynchronous tasks are returned.



          export const sendChatNotification = functions.firestore
        .document('rooms/{roomId}/messages/{messageId}')
        .onCreate((snap, context) => {
        const roomId = context.params.roomId;
        const messageId = context.params.messageId;

        const newValue = snap.data();

        const receiverId = newValue.receiverId;
        const text = newValue.text;
        const type = newValue.type;
        const senderName = newValue.senderName;

        var p = admin
        .firestore()
        .collection('users')
        .doc(receiverId)
        .get();

        return p.then(snapshot2 => { // <- HERE, the promise is returned
        const data2 = snapshot2.data();
        const firebaseNotificationToken = data2.firebaseNotificationToken;

        if (type == 'voiceCall' || type == 'videoCall' || type == 'hangUp') {
        const channelId = newValue.channelId;
        const senderId = newValue.senderId;
        const status = newValue.status;

        console.log('type: ' + type + ' /status: ' + status);

        let message = {
        data: {
        type: type,
        senderId: senderId,
        senderName: senderName,
        receiverId: receiverId,
        status: status,
        channelId: channelId,
        roomId: roomId
        },
        token: firebaseNotificationToken
        };

        return admin.messaging().send(message); // <- HERE, the promise is returned
        }
        });

        });


        I would suggest you watch the 3 videos about "JavaScript Promises" from the Firebase video series: https://firebase.google.com/docs/functions/video-series/






        share|improve this answer













        Your code is a bit messy and it is not really easy to understand it without dedicating a long time.



        However, here is below a piece of code that should work and that cover one case of your Business Logic. Note how the promises returned by the asynchronous tasks are returned.



          export const sendChatNotification = functions.firestore
        .document('rooms/{roomId}/messages/{messageId}')
        .onCreate((snap, context) => {
        const roomId = context.params.roomId;
        const messageId = context.params.messageId;

        const newValue = snap.data();

        const receiverId = newValue.receiverId;
        const text = newValue.text;
        const type = newValue.type;
        const senderName = newValue.senderName;

        var p = admin
        .firestore()
        .collection('users')
        .doc(receiverId)
        .get();

        return p.then(snapshot2 => { // <- HERE, the promise is returned
        const data2 = snapshot2.data();
        const firebaseNotificationToken = data2.firebaseNotificationToken;

        if (type == 'voiceCall' || type == 'videoCall' || type == 'hangUp') {
        const channelId = newValue.channelId;
        const senderId = newValue.senderId;
        const status = newValue.status;

        console.log('type: ' + type + ' /status: ' + status);

        let message = {
        data: {
        type: type,
        senderId: senderId,
        senderName: senderName,
        receiverId: receiverId,
        status: status,
        channelId: channelId,
        roomId: roomId
        },
        token: firebaseNotificationToken
        };

        return admin.messaging().send(message); // <- HERE, the promise is returned
        }
        });

        });


        I would suggest you watch the 3 videos about "JavaScript Promises" from the Firebase video series: https://firebase.google.com/docs/functions/video-series/







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 20 at 11:32









        Renaud TarnecRenaud Tarnec

        10.9k21531




        10.9k21531

























            0














            The problem is you commented the return in your catch block
            As your Firebase .get() function must return a promise, in your code, if it fails, it won't return a promise and it will hang there.



            either use return null or return something to be handled by the calling app






            share|improve this answer
























            • I add return null , return "" , return e ,... but not works!

              – Sadegh
              Jan 20 at 8:21
















            0














            The problem is you commented the return in your catch block
            As your Firebase .get() function must return a promise, in your code, if it fails, it won't return a promise and it will hang there.



            either use return null or return something to be handled by the calling app






            share|improve this answer
























            • I add return null , return "" , return e ,... but not works!

              – Sadegh
              Jan 20 at 8:21














            0












            0








            0







            The problem is you commented the return in your catch block
            As your Firebase .get() function must return a promise, in your code, if it fails, it won't return a promise and it will hang there.



            either use return null or return something to be handled by the calling app






            share|improve this answer













            The problem is you commented the return in your catch block
            As your Firebase .get() function must return a promise, in your code, if it fails, it won't return a promise and it will hang there.



            either use return null or return something to be handled by the calling app







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 19 at 12:16









            MocasMocas

            559312




            559312













            • I add return null , return "" , return e ,... but not works!

              – Sadegh
              Jan 20 at 8:21



















            • I add return null , return "" , return e ,... but not works!

              – Sadegh
              Jan 20 at 8:21

















            I add return null , return "" , return e ,... but not works!

            – Sadegh
            Jan 20 at 8:21





            I add return null , return "" , return e ,... but not works!

            – Sadegh
            Jan 20 at 8:21


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264735%2ferror-firebase-functions-promises-must-be-handled-appropriately-on-deploy%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Homophylophilia

            Updating UILabel text programmatically using a function

            Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage