{"action":"created","issue":{"url":"https://api.github.com/repos/meteor/meteor/issues/3293","labels_url":"https://api.github.com/repos/meteor/meteor/issues/3293/labels{/name}","comments_url":"https://api.github.com/repos/meteor/meteor/issues/3293/comments","events_url":"https://api.github.com/repos/meteor/meteor/issues/3293/events","html_url":"https://github.com/meteor/meteor/issues/3293","id":52001122,"number":3293,"title":"Tracker.afterFlush should bindEnvironment or noYieldsAllowed","user":{"login":"cscott","id":156080,"avatar_url":"https://avatars.githubusercontent.com/u/156080?v=3","gravatar_id":"","url":"https://api.github.com/users/cscott","html_url":"https://github.com/cscott","followers_url":"https://api.github.com/users/cscott/followers","following_url":"https://api.github.com/users/cscott/following{/other_user}","gists_url":"https://api.github.com/users/cscott/gists{/gist_id}","starred_url":"https://api.github.com/users/cscott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cscott/subscriptions","organizations_url":"https://api.github.com/users/cscott/orgs","repos_url":"https://api.github.com/users/cscott/repos","events_url":"https://api.github.com/users/cscott/events{/privacy}","received_events_url":"https://api.github.com/users/cscott/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/meteor/meteor/labels/Project%3ATracker","name":"Project:Tracker","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-12-15T15:46:58Z","updated_at":"2015-01-16T15:44:24Z","closed_at":null,"body":"It appears that Tracker.afterFlush does not use a proper Meteor.bindEnvironment on server-side:\r\n\r\n```\r\nI20141215-10:43:40.962(-5)? Exception from Tracker afterFlush function: Error: Can't wait without a fiber\r\nI20141215-10:43:40.962(-5)?   at Function.wait (/home/cananian/.meteor/packages/meteor-tool/.1.0.36.1m269nh++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/fibers/future.js:83:9)\r\nI20141215-10:43:40.962(-5)?   at Object.Future.wait (/home/cananian/.meteor/packages/meteor-tool/.1.0.36.1m269nh++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/fibers/future.js:325:10)\r\nI20141215-10:43:40.963(-5)?   at [object Object]._.extend._nextObject (/home/cananian/Projects/MysteryHunt/2015/codex-blackboard/.meteor/local/build/programs/server/packages/mongo.js:900:47)\r\nI20141215-10:43:40.967(-5)?   at [object Object]._.extend.forEach (/home/cananian/Projects/MysteryHunt/2015/codex-blackboard/.meteor/local/build/programs/server/packages/mongo.js:934:22)\r\nI20141215-10:43:40.967(-5)?   at [object Object].Cursor.(anonymous function) [as forEach] (/home/cananian/Projects/MysteryHunt/2015/codex-blackboard/.meteor/local/build/programs/server/packages/mongo.js:783:44)\r\nI20141215-10:43:40.968(-5)?   at updateRoundStart (/home/cananian/Projects/MysteryHunt/2015/codex-blackboard/.meteor/local/build/programs/server/app/lib/model.coffee.js:33:8)\r\nI20141215-10:43:40.968(-5)?   at /home/cananian/Projects/MysteryHunt/2015/codex-blackboard/.meteor/local/build/programs/server/app/lib/model.coffee.js:54:18\r\nI20141215-10:43:40.968(-5)?   at [object Object].Tracker.flush [as _onTimeout] (/home/cananian/Projects/MysteryHunt/2015/codex-blackboard/.meteor/local/build/programs/server/packages/tracker.js:421:11)\r\nI20141215-10:43:40.969(-5)?   at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)\r\n```\r\n\r\nThe code in question looks like this:\r\n```coffeescript\r\n# RoundGroups are:\r\n#   _id: mongodb id\r\n#   name: string\r\n#   canon: canonicalized version of name, for searching\r\n#   created: timestamp (sort key)\r\n#   created_by: canon of Nick\r\n#   touched: timestamp -- records edits to tag, order, group, etc.\r\n#   touched_by: canon of Nick with last touch\r\n#   tags: [ { name: \"Status\", canon: \"status\", value: \"stuck\" }, ... ]\r\n#   rounds: [ array of round _ids, in order ]\r\n#   (next fields is a bit racy, oh well)\r\n#   round_start: integer, indicating how many rounds total are in all\r\n#                preceding round groups (a bit racy, but server fixes it up)\r\nRoundGroups = BBCollection.roundgroups = new Mongo.Collection \"roundgroups\"\r\nif Meteor.isServer\r\n  RoundGroups._ensureIndex {canon: 1}, {unique:true, dropDups:true}\r\n  updateRoundStart = ->\r\n    round_start = 0\r\n    RoundGroups.find({}, sort: [\"created\"]).forEach (rg) ->\r\n      if rg.round_start isnt round_start\r\n        RoundGroups.update rg._id, $set: round_start: round_start\r\n      round_start += rg.rounds.length\r\n  queueUpdateRoundStart = do ->\r\n    pending = false\r\n    return ->\r\n      if not pending\r\n        pending = true\r\n        Tracker.afterFlush ->\r\n          pending = false\r\n          updateRoundStart()\r\n  # observe changes to the rounds field and update round_start\r\n  queueUpdateRoundStart()\r\n  RoundGroups.find({}).observeChanges\r\n    added: (id, fields) -> queueUpdateRoundStart()\r\n    removed: (id, fields) -> queueUpdateRoundStart()\r\n    changed: (id, fields) ->\r\n      queueUpdateRoundStart() if 'created' in fields or 'rounds' in fields\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/meteor/meteor/issues/comments/70271945","html_url":"https://github.com/meteor/meteor/issues/3293#issuecomment-70271945","issue_url":"https://api.github.com/repos/meteor/meteor/issues/3293","id":70271945,"user":{"login":"mitar","id":585279,"avatar_url":"https://avatars.githubusercontent.com/u/585279?v=3","gravatar_id":"","url":"https://api.github.com/users/mitar","html_url":"https://github.com/mitar","followers_url":"https://api.github.com/users/mitar/followers","following_url":"https://api.github.com/users/mitar/following{/other_user}","gists_url":"https://api.github.com/users/mitar/gists{/gist_id}","starred_url":"https://api.github.com/users/mitar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitar/subscriptions","organizations_url":"https://api.github.com/users/mitar/orgs","repos_url":"https://api.github.com/users/mitar/repos","events_url":"https://api.github.com/users/mitar/events{/privacy}","received_events_url":"https://api.github.com/users/mitar/received_events","type":"User","site_admin":false},"created_at":"2015-01-16T15:44:24Z","updated_at":"2015-01-16T15:44:24Z","body":"What about this old code: https://github.com/Diggsey/meteor-server-deps/blob/master/lib/server-deps.coffee It seems to do all necessary stuff?"}}