Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Error: yield() called with no fiber running #10

Closed
yorkie opened this Issue Feb 25, 2013 · 6 comments

Comments

Projects
None yet
3 participants

yorkie commented Feb 25, 2013

I need a help, my code like this:

var Server = MongoSync.Server;
var server = new Server('127.0.0.1');
var result = server.db("LashDB").getCollection("users").find().toArray();

MongoSync is require('mongo-sync')

Owner

olegp commented Feb 25, 2013

You need to wrap all synchronous calls in a fiber if you're using fibers directly, e.g.:

var Fiber = require('fibers'); Fiber(function() { var result = server.db("LashDB").getCollection("users").find().toArray(); });

... or just install Common Node with npm install -g common-node and run your program with common-node app.js instead of node app.js. Common Node sets up the fiber for you and provides a bunch of other sync APIs.

@olegp olegp closed this Feb 25, 2013

yorkie commented Feb 25, 2013

@olegp
Thanks, I think your project notes is achieved it by latter way.

olegp added a commit that referenced this issue Feb 25, 2013

Owner

olegp commented Feb 25, 2013

Yes. Thanks for highlighting this point. I've updated the README to make it more clear that you need to run inside a fiber.

yorkie commented Feb 25, 2013

missing a .run() - !

Fiber(function() {
  // body
}).run()

-.^

Owner

olegp commented Feb 25, 2013

Good catch! ;)

olegp added a commit that referenced this issue Feb 25, 2013

The "Here is a quick usage example" section is still out of date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment