setTimeout inside a callback failed to remove a mongodb document
<p>This Meteor server code tries to remove the current user document in the callback to <code>update</code> but fails to do so.<br>
What is wrong and how to fix it? Thanks</p>



<pre class="lang-js prettyprint-override"><code>Meteor.users.update({
  _id: userId
}, {
  $set: {
    'profile.a': 'A'
  }
}, (err) =&gt; {
  if (!err) {
    console.log('will remove this user');  //prints OK
    setTimeout(function() {
      Meteor.users.remove({
        _id: userId
      }, function(err) {
        if (!err) {
          console.log('user removed');  //unreached, not fired
        } else {
          console.log(err.reason);      //&lt;= prints undefined
        }
      });
    }, 2000);
  }
});
</code></pre>

<p><strong>edit</strong><br>
As Srle in the comments suggested, here is the error object</p>

<blockquote>
  <p>[Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.]</p>
</blockquote>