Tôi đang tạo một ứng dụng sao băng khá đơn giản lần đầu tiên được yêu cầu truy vấn tất cả các vấn đề git từ một repo nhất định. Sau khi nó nhận được một danh sách các vấn đề từ api github, ý tưởng là tạo ra một tập hợp các nhiệm vụ từ những vấn đề này. Tuy nhiên, bất cứ khi nào tôi cố gắng để truy vấn danh sách các nhiệm vụ hiện tại tôi nhận được:Tìm nạp các mục từ bộ sưu tập Meteor trên máy chủ ném "Không thể đợi nếu không có sợi"
.../.meteor/tools/c2a0453c51/lib/node_modules/fibers/future.js:83
W20140418-17:00:43.872(-7)? (STDERR) throw new Error('Can\'t wait without a fiber');
W20140418-17:00:43.872(-7)? (STDERR) ^
W20140418-17:00:43.889(-7)? (STDERR) Error: Can't wait without a fiber
W20140418-17:00:43.889(-7)? (STDERR) at Function.wait
(.../.meteor/tools/c2a0453c51/lib/node_modules/fibers/future.js:83:9)
W20140418-17:00:43.890(-7)? (STDERR) at Object.Future.wait
(.../.meteor/tools/c2a0453c51/lib/node_modules/fibers/future.js:325:10)
W20140418-17:00:43.890(-7)? (STDERR) at _.extend._nextObject (packages/mongo-
livedata/mongo_driver.js:805)
W20140418-17:00:43.890(-7)? (STDERR) at _.extend.forEach (packages/mongo-livedata/mongo_driver.js:836)
W20140418-17:00:43.890(-7)? (STDERR) at Cursor.(anonymous function) [as forEach] (packages/mongo-
livedata/mongo_driver.js:695)
W20140418-17:00:43.890(-7)? (STDERR) at app/server/publish.js:51:33
W20140418-17:00:43.890(-7)? (STDERR) at Array.forEach (native)
W20140418-17:00:43.891(-7)? (STDERR) at app/server/publish.js:49:19
W20140418-17:00:43.891(-7)? (STDERR) at
...packages/npm/.build/npm/node_modules/github/api/v3.0.0/issues.js:116:17
W20140418-17:00:43.891(-7)? (STDERR) at IncomingMessage.<anonymous>
(...packages/npm/.build/npm/node_modules/github/index.js:756:21)
Suy nghĩ đầu tiên của tôi là tôi đã sử dụng một callback ở đâu đó khi tôi đã được yêu cầu được sử dụng một nút-xơ, nhưng mã dường như tương đối đơn giản:
var repos = ['my-repo', 'my-repo-1',];
var pollGit = function() {
repos.forEach(function(repo) {
github.issues.repoIssues({
user: 'user',
repo: repo
}, function(err, stuff) {
if (err) {
throw err;
}
stuff.forEach(function (issue) {
var sel = {git_id: issue.id};
Tasks.find(sel).forEach(function (item) { //ERROR THROWN HERE
console.log('got', item);
});
});
});
});
};
Meteor.startup(function() {
pollGit();
});
Lỗi này xảy ra bất cứ khi nào tôi thử và tìm nạp đối tượng thực sau khi gọi tìm. Chỉ cần gọi find() hoạt động tốt. Chính xác thì điều gì gây ra lỗi?
thấy câu trả lời này: http://stackoverflow.com/questions/10192938/meteor-code-must-always-run-within-a-fiber-when-calling-collection-insert- on-s/18541825 # 18541825 – imslavko