title: Firestore cloud function working on emulator as expected but not after deployment on firestore
body: <p>My cloud function is working perfectly on firebase emulator although after deploying into firestore, it doesn't work. The function executes although nothing happens.</p>
  <p>It was working in firestore before introducing the if statement for statusValue. Although, even after the introduction of the if statement, it is still working as expected in the emulator.</p>
  <p>I've deleted and redeployed the functions and installed the latest version of node with no success.</p>
  <p>Appreciate the help!</p>
  <pre><code>const functions = require(&quot;firebase-functions&quot;);
  const admin = require('firebase-admin');
  admin.initializeApp();
  
  // capture group members when a new message is added to a group to notify them
  exports.newMessage = functions.region('australia-southeast1')
  .firestore
  .document('ChatRooms/{chatRoomsID}/Messages/{messageID}')
  .onCreate(async (snap, context) =&gt; {
    const messageData = snap.data();
    const messageSender = messageData.fullName;
  
    // access the documentRef at collection level
    const chatRoomRef = snap.ref.parent.parent;
  
    // access the data at collection level
    const chatRoomSnap = await chatRoomRef.get();
    const chatRoomData = chatRoomSnap.data();
    const groupMembers = chatRoomData.members;
    const activeUsers = chatRoomData.activeUserStatus;
    const chatRoomTitle = chatRoomData.chatRoomTitle;
    const notificationTitle = `ChatRoom: ${chatRoomTitle}`
    const notificationBody = `${messageSender} sent a message`;
  
    groupMembers.forEach((item, i) =&gt; {
  
      const statusValue = activeUsers[item]
  
      if (statusValue == 0) {
        const topic = item.replace(/[^a-zA-Z0-9]/g,'-');
  
        const message = {
          notification : {
              title : notificationTitle,
              body: notificationBody
          },
          apns: {
            payload: {
              aps: {
                sound : `default`
              }
            }
          },
          topic: topic,
        };
        // send notification subscribed to topic
        admin.messaging().send(message).then((response) =&gt; {
          console.log(`Successfully sent message to ${topic}`, response);
        }).catch((error) =&gt; {
          console.log('Error sending message:', error);
        });
      };
    });
  });
  </code></pre>
  <p>The above is working in the emulator, see logs:</p>
  <p>i  functions: Beginning execution of &quot;australia-southeast1-newMessage&quot;</p>
  <p>i  functions: Finished &quot;australia-southeast1-newMessage&quot; in ~1s</p>
  <p>Successfully sent message to 5-3-com projects/</p>
  <p>Successfully sent message to 3-4-com projects/</p>
  <p>When deployed into firestore, the logs in firestore functions show the function executing without any messages being sent to the topic.</p>
  <p>7:53:04.745 am
  newMessage
  Function execution started</p>
  <p>7:53:05.807 am
  newMessage
  Function execution took 1063 ms, finished with status: 'ok'</p>