node-fibers

Writing/Converting Meteor Synchronous Functions

依然范特西╮ 提交于 2019-12-10 14:42:45
问题 This has been bothering me for a while so I thought I'd just do a quick QA on it: If one has a normal nodeJS module or something and it has a async function on the server side. How do I make it synchronous. E.g how would I convert the nodejs fs.stat asynchronous function to a synchronous one. e.g I have server side js Meteor.methods({ getStat:function() { fs.stat('/tmp/hello', function (err, result) { if (err) throw err; console.log(result) }); } }); If I call it from the client I get back

Meteor (Fibers) loop and callback

落爺英雄遲暮 提交于 2019-12-09 23:50:14
问题 Meteor fibers "sync" mode is driving me crazy. Here is a simple code example : var feedsData = feeds.fetch(); // [{_id: "1234"}, {_id: "6789", url: "http://...."}] for(var i = 0, len = feedsData.length; i < len; i++) { var feed = feedsData[i]; parser.parseURL(feed.url, function(err, out){ console.log(feed._id, i); // outputs "6789" and "2" each times }); } I don't understand how to make this work. The callback is called after the loop is over, but the internal internal variables such as feed

imagemagick in meteorjs (with the help of meteor-router and fibers)

一世执手 提交于 2019-12-07 14:35:30
问题 I am unable to use imagemagick in meteorjs. I am working on a small svg->png converter which contains a rest api to provide the converted images. I implemented the rest api with meteor-router. The imagemagick convertion works. But, I am not able to write the result of the convertion into the http response. I tried to fix this by getting rid of the asynchronisity by using fiber. But this still doesn't work. Basically, all request.write calls are ignored after the yield execution. Here is my

Problems with Meteor deployment related to fibers module

假如想象 提交于 2019-12-04 19:53:13
问题 While trying to deploy meteor, I install node fiber by: $ cd bundle/server and then installing fiber $ npm install fibers It seems to install but with this message: `linux-x64-v8-3.14` exists; testing Binary is fine; exiting fibers@1.0.1 node_modules/fibers However, while deploying the code using: node bundle/main.js I get this error: throw new Error('`'+ modPath+ '.node` is missing. Try reinstalling `node-fibe ~/main_repo/bundle/server/node_modules/fibers/bin/linux-x64-v8-3.20/fibers.node`

Nodejs (Sync) cannot find fibers binaries

不问归期 提交于 2019-12-04 13:31:34
问题 I've seen similar questions but no real solution that worked for me yet (most users just reinstall fibers or meteor (I'm not using meteor)). I've added the nodejs module Sync to my nodejs 0.12.6 project. It's dependency is the Fibers module that got installed automatically with Sync. Now I wanted to load Sync via require, but it fails with the message ... /win32-x64-v8-4.3/fibers.node not found And it's correct: In sync/node_modules/fibers/bin/ is no directory named win32-x64-v8- 4.3, only

Problems with Meteor deployment related to fibers module

瘦欲@ 提交于 2019-12-03 13:03:58
While trying to deploy meteor, I install node fiber by: $ cd bundle/server and then installing fiber $ npm install fibers It seems to install but with this message: `linux-x64-v8-3.14` exists; testing Binary is fine; exiting fibers@1.0.1 node_modules/fibers However, while deploying the code using: node bundle/main.js I get this error: throw new Error('`'+ modPath+ '.node` is missing. Try reinstalling `node-fibe ~/main_repo/bundle/server/node_modules/fibers/bin/linux-x64-v8-3.20/fibers.node` is missing. Try reinstalling `node-fibers`? I can see that the versions are different for linux-x64-v8-3

What's going on with Meteor and Fibers/bindEnvironment()?

血红的双手。 提交于 2019-11-27 08:54:29
I am having difficulty using Fibers/Meteor.bindEnvironment(). I tried to have code updating and inserting to a collection if the collection starts empty. This is all supposed to be running server-side on startup. function insertRecords() { console.log("inserting..."); var client = Knox.createClient({ key: apikey, secret: secret, bucket: 'profile-testing' }); console.log("created client"); client.list({ prefix: 'projects' }, function(err, data) { if (err) { console.log("Error in insertRecords"); } for (var i = 0; i < data.Contents.length; i++) { console.log(data.Contents[i].Key); if (data

“Meteor code must always run within a Fiber” when calling Collection.insert on server

只谈情不闲聊 提交于 2019-11-26 20:06:06
I have the following code in server/statusboard.js; var require = __meteor_bootstrap__.require, request = require("request") function getServices(services) { services = []; request('http://some-server/vshell/index.php?type=services&mode=json', function (error, response, body) { var resJSON = JSON.parse(body); _.each(resJSON, function(data) { var host = data["host_name"]; var service = data["service_description"]; var hardState = data["last_hard_state"]; var currState = data["current_state"]; services+={host: host, service: service, hardState: hardState, currState: currState}; Services.insert(

What's going on with Meteor and Fibers/bindEnvironment()?

时光怂恿深爱的人放手 提交于 2019-11-26 17:47:29
问题 I am having difficulty using Fibers/Meteor.bindEnvironment(). I tried to have code updating and inserting to a collection if the collection starts empty. This is all supposed to be running server-side on startup. function insertRecords() { console.log("inserting..."); var client = Knox.createClient({ key: apikey, secret: secret, bucket: 'profile-testing' }); console.log("created client"); client.list({ prefix: 'projects' }, function(err, data) { if (err) { console.log("Error in insertRecords"

How to wrap async function calls into a sync function in Node.js or Javascript?

不打扰是莪最后的温柔 提交于 2019-11-26 14:10:39
Suppose you maintain a library that exposes a function getData . Your users call it to get actual data: var output = getData(); Under the hood data is saved in a file so you implemented getData using Node.js built-in fs.readFileSync . It's obvious both getData and fs.readFileSync are sync functions. One day you were told to switch the underlying data source to a repo such as MongoDB which can only be accessed asynchronously. You were also told to avoid pissing off your users, getData API cannot be changed to return merely a promise or demand a callback parameter. How do you meet both