title: promise returns timdeout 5000ms, when the promise function is called recursive in cucumber step def
body: <p>I want to repeat the operation <code>getRunDetailsStaus()</code> until the status is done.
  So I put the condition in <code>.then()</code> handler, and I called recursive the funtion next() until the status is DONE.
  <code>getStatus(runDetailsId)</code> is a promise function that returns the status from mongoDB</p>
  <p>See below my step definition:</p>
  <p>When('the user waits until receive the status DONE',</p>
  <pre><code>    let start = Date.now()
  
      function getRunDetailsStaus() {
          return getStatus(runDetailsId) //promise function and returns the status from mongoDB
      }
  
      function next() {
          return getRunDetailsStaus().then(function (result) {
  
              console.log(&quot;status: &quot;, result.runStatus, Date.now() - start)
              if (status == 'DONE') {
                  return status
              }
              else {
                  return next()
              }
          })
  
      }
  
      return next()
          .then((response) =&gt; {
              // process final results
          })
          .catch((error) =&gt; {
              //process error
          })
  });```
  
  But I get the following error: 
  function timed out, ensure the promise resolves within 5000 milliseconds
  
  
  How should I resolve this issue in case the status done in mongo is set in ~30 min?
  </code></pre>