我在 mongohq 使用外部 mongo 实例,所以我有
MONGO_URL=mongodb://heroku:censored@alex.mongohq.com:10025/appCensored
在我的环境中。我在“只读”模式下使用这个 mongo 实例,使用我的流星应用程序作为监控应用程序。所有集合中的 _id 都不是流星 uuid。
当我启动流星并将客户端连接到 localhost:3000 时,我在服务器上收到以下晦涩的错误消息:
Internal exception while processing message { msg: 'sub',
id: '9e11edd5-b8a5-4a67-86de-a3270ef3601f',
name: 'content',
params: [ 'ORG-4d9d4981-55d8-44ee-9025-32c41be679ca' ] } Error: Can't call yield in a noYieldsAllowed block!
at Function.Meteor._noYieldsAllowed.Fiber.yield (app/packages/meteor/fiber_helpers.js:13:11)
at Function.wait (/usr/local/meteor/lib/node_modules/fibers/future.js:111:14)
at Object.Future.wait (/usr/local/meteor/lib/node_modules/fibers/future.js:321:10)
at _Mongo._createSynchronousCursor (app/packages/mongo-livedata/mongo_driver.js:369:23)
at _Mongo._observe (app/packages/mongo-livedata/mongo_driver.js:493:14)
at Object.Meteor._noYieldsAllowed (app/packages/meteor/fiber_helpers.js:17:12)
at _Mongo._observe (app/packages/mongo-livedata/mongo_driver.js:485:10)
at Cursor._observeUnordered (app/packages/mongo-livedata/mongo_driver.js:344:22)
at Cursor._publishCursor (app/packages/mongo-livedata/mongo_driver.js:305:28)
at sub._runHandler (app/packages/livedata/livedata_server.js:378:13)
而且我在客户端的“内容”集合中没有任何文档。当我刷新浏览器并将客户端重新连接到服务器时,一切顺利,我在“内容”中获得了文档。订阅“内容”集合似乎有问题。此集合的发布和订阅代码如下:
server.coffee
-------------
Content = new Meteor.Collection 'content'
Meteor.publish 'content', (org) ->
Content.find { recipientUid: org }
client.coffee
-------------
Content = new Meteor.Collection 'content'
Meteor.autosubscribe ->
uid = Session.get 'testUserUid'
if uid
Meteor.subscribe 'content', uid
Template.main.top_content = ->
# observe won't work with limited collections, use workaround
top = Content.find({}, { sort: { total: -1 } }).fetch()
top.slice 0, 10
我做错了什么?