title: "Error: 13 INTERNAL: An internal error occurred" happened in firebase-function's trigger sometimes
body: <p>This trigger is used for detecting sequence in schedule has been updated, and help to update the schedule's overview status and finished time. </p>
  
  <p>But it didn't always work when an internal error was occurred as below: </p>
  
  <pre><code>Error: 13 INTERNAL: An internal error occurred. at Object.exports.createStatusError 
  (/srv/node_modules/grpc/src/common.js:91:15) at Object.onReceiveStatus 
  (/srv/node_modules/grpc/src/client_interceptors.js:1204:28) at InterceptingListener._callNext 
  (/srv/node_modules/grpc/src/client_interceptors.js:568:42) at InterceptingListener.onReceiveStatus 
  (/srv/node_modules/grpc/src/client_interceptors.js:618:8) at callback 
  (/srv/node_modules/grpc/src/client_interceptors.js:845:24)
  
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>export const calc_status = function.firestore.document("users/{userid}/schedule/{scheduledid}").onUpdate(async (change, context) =&gt; {
      // before error occurred ...
      const data = change.after.data();
      let curStatus = data.status;
      ...
      ...
  
      // after getting occurred ...
      if(data.status !== curStatus ) {
          data.status = curStatus;
          if(curStatus === 'finished') {
              data.finish_time = new Date().toISOString();
          }
          if(curStatus !== 'expired'){
              data.update_time = data.expired_time;
              data.finish_time = data.expired_time;
          } else {
              data.update_time = new Date().toISOString();
          }
          await change.after.ref.update(data);
          return Status.SUCCEEDED;
      }
      return Status.SUCCEEDED;
  }
  </code></pre>
  
  <p>I'm very confused why the error occurred because this function works fine at most time.</p>
  
  <p>Does anyone met the same problem as mine? </p>
  
  <p>Why the error happened? And what's your solution?</p>
  
  <p>Thank you.</p>