I have firebase project that has few cloud functions. Some of them sends push notifications to the users. Before deploying any function, I develop it using the nodeJS on my local environment with standalone nodejs project.
However today I noticed that the function execution gets stuck after I try to send a push notification to even a single user. I mean to say the cursor does not return after I hit the node test.js and the execution never stops. I need to do ctrl + z in order to end the execution. However I get the push notification.
My code:
async function sendTest() {
await admin.messaging().sendToDevice(token, payload);
console.debug('Message Sent'); // this line gets printed instantly but execution continues
}
The following is also a similar code but it also doesn't end the execution even after printing the debug. statement.
async function sendTest() {
var notificationPersonalPromises = []
notificationPersonalPromises.push(admin.messaging().sendToDevice(token, payload));
await Promise.all(notificationPersonalPromises);
console.debug('Message Sent'); // this line gets printed instantly but execution continues
}
In both the above cases, I get the notification in couple of seconds and the debug gets printed instantly. If I comment out the push notification code then everything works fine. Please help...
The following image shows how the functions never ends the cursor keeps waiting...
Thanks