title: Firebase functions work correctly but finish always with timeout status
body: <p>I'm here to find a solutions for my project that use Firebase Firestore and Cloud Functions.
  <br /><br /></p>
  <h2>The problem maker</h2>
  <p>Until yesterday morning everything worked perfectly. In the afternoon I read through the console that &quot;npm&quot; and Node could be updated. So I did it and the problems began.
  <br /><br /></p>
  <h3>The problem:</h3>
  <p>As first I had the famous &quot;<em>$RESOURCE_DIR</em>&quot; problem, solved replacing that string with &quot;<em>functions</em>&quot;. After that, I can compile and publish functions on Firebase <strong>(whitout edit them)</strong>, they work correctly but have a (big) issue:
  in the console log on Firebase platform, I always read foreach functions that it's closed with status <strong>timeout</strong> even it finished <em><strong>correctly</strong></em>.</p>
  <p>In the console I can read the message</p>
  <blockquote>
  <p>Successfully sent message....</p>
  </blockquote>
  <p>and I receive the notification on device, but after 60s I receive</p>
  <blockquote>
  <p>Function execution took 60002 ms, finished with status: 'timeout'</p>
  </blockquote>
  <p>Well... here is where I can't understand how to fix the problem. Can anyone help me please?
  <br /><br />
  <strong>This is one of the simply functions that generate the error:</strong></p>
  <pre><code>const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  admin.initializeApp();
  const db = admin.firestore();
  
  exports.notifyProfileApproved = functions.firestore.document('/users/{user_id}')
      .onUpdate((change , context) =&gt; {
          const approvedBefore = change.before.data().approved;
          const approvedAfter = change.after.data().approved;
          
          if(approvedBefore === false &amp;&amp; approvedAfter === true){
              var registrationToken = change.after.data().registrationToken;
              
              var message = {
                  notification: {
                      title: 'Approved profile',
                      body: 'Your profile has been approved!'
                  },
                  token : registrationToken
              };
              
              return admin.messaging().send(message)
              .then((response) =&gt;{
                  return console.log('Successfully sent message: ', response);
              })
              .catch((error) =&gt;{
                  return console.log('Error sending message: ', error);
              });)
          }else{
              return console.log('Profile edited but not approved');
          }
      });
  </code></pre>
  <p><strong>Here there's my system infos:</strong><br />
  npm: 4.2.0<br />
  node: 7.10.0<br />
  firebase: 4.0.0</p>
  <h1>UPDATE</h1>
  <p>On 17 July 2018 I received a Firebase email that tell me that my project was been automatic updated to <strong>Blaze plan</strong> because there was changes on Google Cloud Platform, but I never entered a <strong>billing method</strong>.
  Without doing apparently anythings (only restart PC, re-deploy and switch to FREE <strong>Spark Plan</strong>), now execution time was from 50ms to 350ms, so it's OK!</p>
  <p>A new error appear in the console even the functions work correctly. The error is:</p>
  <blockquote>
  <p>Function returned undefined, expected Promise or value</p>
  </blockquote>
  <p>The function code was the same as this above. To fix that, I must returned a value everytime I haven't a promise.. so, I changed every</p>
  <pre><code>return console.log('', response);
  </code></pre>
  <p>with</p>
  <pre><code>console.log('', response);
  return 0;
  </code></pre>
  <p>Now all works perfectly!</p>