title: MongoDB atlas trigger - execution time limit exceeded
body: <p>I'm testing out a trigger on MongoDB atlas which runs a Realm function for adding an object to Algolia index upon insertion to the MongoDB collection. In my case the record gets uploaded to Algolia index successfully but the function doesn't stop there and happens to exceed the time limit.</p>
  <p>The docs mention that</p>
  <blockquote>
  <p>Function runtime is limited to 120 seconds</p>
  </blockquote>
  <p>and that's the reason for the function to timeout</p>
  <p>Here is my Realm function</p>
  <pre class="lang-js prettyprint-override"><code>exports = function(changeEvent) {
    
    const algoliasearch = require('algoliasearch');
    const client = algoliasearch(context.values.get('algolia_app'),context.values.get('algolia_key'));
  
    const index = client.initIndex(&quot;movies&quot;);
  
  
    changeEvent.fullDocument.objectID = changeEvent.fullDocument._id;
    delete changeEvent.fullDocument._id;
    index.saveObject(changeEvent.fullDocument)
    .then(({objectID}) =&gt; {
      console.log('successfully inserted: ',objectID);
    })
    .catch(err =&gt; {
      console.log(err);
    });
  };
  </code></pre>
  <p>Here is the result I get on the logs</p>
  <pre><code>Logs:
  [
    &quot;successfully inserted:  61cf0a79c577393620dd8c80&quot;
  ]
  Error:
  execution time limit exceeded
  </code></pre>
  <p>I even tried with <code>return</code> statements after the <code>console.log</code>s but still the same issue.</p>
  <p>What I'm I doing wrong</p>