Note that there are some explanatory texts on larger screens.

plurals
  1. POMeteor, Error: Can't wait without a fiber using Meteor.setTimeout() on the server
    text
    copied!<p>I'm fairly new to Meteor so I might be missing a key insight here. </p> <p>Anyway, I want to indicate to users how many other users is on the site at the same time. I have an <code>AuditItems</code> collection already that stores kv-pairs for <code>who</code>, <code>when</code> and <code>what</code> that I can use for this type of computation. My <code>Collections</code> query is run with a <code>new Date()</code> parameter so I can't just observe the results, I have to rerun the query periodically.</p> <p>I then <em>made</em> it reactive by calling <code>changed</code> on a <code>Deps.Dependency</code>. </p> <p>Here is the code:</p> <pre><code> // publishing counts of the users that are logged on // at the moment Meteor.publish("user-activity", function () { var self = this; self.added("user-activity", "all-recent-activity", {'operations': getRecentActivityCountsCache}); self.ready(); Deps.autorun(function() { self.changed("user-activity", "all-recent-activity", {'operations': getRecentActivityCounts()}); }); }); var getRecentActiveCountsDependency = new Deps.Dependency; var getRecentActivityCountsCache = 0; var getRecentActivityCounts = function() { // register dependency with the caller getRecentActiveCountsDependency.depend(); var now = new Date(); var aWhileAgo = new Date(now.valueOf() - (5 * 60 * 1000)); // 5 minutes auditItems = AuditItems.find({'when': { '$gt': aWhileAgo }}).fetch(); console.log('raw data: ' + JSON.stringify(auditItems)); getRecentActivityCountsCache = _.chain(auditItems) .groupBy('who') .keys() .size() .value(); console.log('new count: ' + getRecentActivityCountsCache); return getRecentActivityCountsCache; }; Meteor.setTimeout(function() { getRecentActiveCountsDependency.changed(); }, 60 * 1000); // 60 seconds </code></pre> <p>I am getting this error on the console the first time the timer fires:</p> <pre><code> Exception from Deps recompute: Error: Can't wait without a fiber at Function.wait (/home/vagrant/.meteor/tools/3cba50c44a/lib/node_modules/fibers/future.js:83:9) at Object.Future.wait (/home/vagrant/.meteor/tools/3cba50c44a/lib/node_modules/fibers/future.js:325:10) at _.extend._nextObject (packages/mongo-livedata/mongo_driver.js:540) at _.extend.forEach (packages/mongo-livedata/mongo_driver.js:570) at _.extend.map (packages/mongo-livedata/mongo_driver.js:582) at _.extend.fetch (packages/mongo-livedata/mongo_driver.js:606) at _.each.Cursor.(anonymous function) [as fetch] (packages/mongo-livedata/mongo_driver.js:444) at getRecentActivityCounts (app/server/server.js:26:70) at null._func (app/server/server.js:12:79) at _.extend._compute (packages/deps/deps.js:129) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload