Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spiderable fiber issue #1192

Open
wolasss opened this issue Jan 22, 2015 · 52 comments
Open

Spiderable fiber issue #1192

wolasss opened this issue Jan 22, 2015 · 52 comments

Comments

@wolasss
Copy link

wolasss commented Jan 22, 2015

Well, I had some issues with iron router and spiderable on production environment (similar to this: issue 1069 and stack overflow question), and I managed to reproduce the bug on clean meteor instance with iron router.

So steps are:

meteor create app
cd app
meteor add iron:router
meteor add spiderable

Now run the application, and visit site at "http://localhost:3000/?_escaped_fragment_=". And server logs following error:

I20150122-23:59:24.062(1)? spiderable: phantomjs failed: { [Error: Command failed: ] killed: true, code: null, signal: 'SIGTERM' }
I20150122-23:59:24.063(1)? stderr:
W20150122-23:59:24.064(1)? (STDERR) Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
W20150122-23:59:24.064(1)? (STDERR)     at Object.Meteor._nodeCodeMustBeInFiber (packages/meteor/dynamics_nodejs.js:9:1)
W20150122-23:59:24.064(1)? (STDERR)     at [object Object]._.extend.get (packages/meteor/dynamics_nodejs.js:21:1)
W20150122-23:59:24.064(1)? (STDERR)     at [object Object].RouteController.lookupOption (packages/iron:router/lib/route_controller.js:66:1)
W20150122-23:59:24.064(1)? (STDERR)     at new Controller.extend.constructor (packages/iron:router/lib/route_controller.js:26:1)
W20150122-23:59:24.065(1)? (STDERR)     at [object Object].ctor (packages/iron:core/lib/iron_core.js:88:1)
W20150122-23:59:24.065(1)? (STDERR)     at Function.Router.createController (packages/iron:router/lib/router.js:201:1)
W20150122-23:59:24.065(1)? (STDERR)     at Function.Router.dispatch (packages/iron:router/lib/router_server.js:39:1)
W20150122-23:59:24.065(1)? (STDERR)     at Object.router (packages/iron:router/lib/router.js:15:1)
W20150122-23:59:24.065(1)? (STDERR)     at next (/Users/wolas/.meteor/packages/webapp/.1.1.6.ik9rx6++os+web.browser+web.cordova/npm/node_modules/connect/lib/proto.js:190:15)
W20150122-23:59:24.065(1)? (STDERR)     at packages/spiderable/spiderable_server.js:123:1

Meteor version: 1.0.3.1
phantomjs version: 1.9.8,
node: v0.10.29
mac os x

Seems critical to me.

@wolasss
Copy link
Author

wolasss commented Jan 22, 2015

Well, funny thing, I've checked on linux and it works and also it works in meteor bundle. I am gonna try to reproduce it from my production environment again.

@Elfoslav
Copy link

I have the same issue on Ubuntu 14.04

@timothyarmes
Copy link

I also have this issue on Ubuntu 14.10. It works perfectly on the local host.

@timothyarmes
Copy link

Also, I noticed this in my logs when I start up the server, I wonder if it's related:

[<ip>] Warning: Permanently added '<ip>' (RSA) to the list of known hosts.
[<ip>] at Object.router (packages/iron:router/lib/router.js:15:1)
at next (/opt/abesea/app/programs/server/npm/webapp/node_modules/connect/lib/proto.js:190:15)
at packages/spiderable/spiderable_server.js:123:1

It happens every time, so it isn't really managing to permanantly add the ip address to the list of known hosts

@timothyarmes
Copy link

More info. On my local server it works perfectly, UNLESS I get the URL slightly wrong. For example:

http://localhost:3000/logbook/personal??_escaped_fragment_=

(Note the two ?'s)

In this case I get the EXACT same error message continually thrown to the console. I have to quit meteor to return to normal.

In the case of the Digital Ocean deployment I am using the correct URL, but I get the same error thrown.

@themeteorchef
Copy link

Running into a similar problem. Tried all fixes listed on line but nothing works. Getting this output when I hit http://localhost:3000/route/path?_escaped_fragment_= (same problem on singular routes, too):

I20150131-21:41:23.630(-6)? spiderable: phantomjs failed: { [Error: Command failed: ] killed: true, code: null, signal: 'SIGTERM' }
I20150131-21:41:23.633(-6)? stderr:
W20150131-21:41:23.633(-6)? (STDERR) Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
W20150131-21:41:23.634(-6)? (STDERR)     at Object.Meteor._nodeCodeMustBeInFiber (packages/meteor/dynamics_nodejs.js:9:1)
W20150131-21:41:23.637(-6)? (STDERR)     at [object Object]._.extend.get (packages/meteor/dynamics_nodejs.js:21:1)
W20150131-21:41:23.653(-6)? (STDERR)     at [object Object].RouteController.lookupOption (packages/iron:router/lib/route_controller.js:66:1)
W20150131-21:41:23.654(-6)? (STDERR)     at new Controller.extend.constructor (packages/iron:router/lib/route_controller.js:26:1)
W20150131-21:41:23.654(-6)? (STDERR)     at [object Object].ctor (packages/iron:core/lib/iron_core.js:88:1)
W20150131-21:41:23.654(-6)? (STDERR)     at Function.Router.createController (packages/iron:router/lib/router.js:201:1)
W20150131-21:41:23.654(-6)? (STDERR)     at Function.Router.dispatch (packages/iron:router/lib/router_server.js:39:1)
W20150131-21:41:23.655(-6)? (STDERR)     at Object.router (packages/iron:router/lib/router.js:15:1)
W20150131-21:41:23.655(-6)? (STDERR)     at next (/Users/rglover/.meteor/packages/webapp/.1.1.6.ddr9ea++os+web.browser+web.cordova/npm/node_modules/connect/lib/proto.js:190:15)
W20150131-21:41:23.656(-6)? (STDERR)     at Object.WebApp.rawConnectHandlers.use.contentTypeOptions [as handle] (packages/browser-policy-common/browser-policy-common.js:28:1)

I've run through the troubleshooting guide over on Meteorpedia a handful of times to no avail.

@dasmodel
Copy link

Anyone found a workaround for this?

@themeteorchef
Copy link

@dasmodel Nothing yet. Anybody else?

@wolasss
Copy link
Author

wolasss commented Feb 16, 2015

Well, I used ongoworks:spiderable, which uses Docker to run spiderable and it solved this issue and another one (/dev/stdin error), maybe you can try that as well

@Volvox
Copy link

Volvox commented Feb 16, 2015

I think it may be an issue with some of the iron-router middleware not using Meteor.bindEnvironment. Someone would need to submit a pull request to fix.

@themeteorchef
Copy link

Attempting this now and getting similar output. Again, just visiting http://localhost:3000/route/path?_escaped_fragment_=:

I20150216-16:08:31.862(-6)? spiderable: phantomjs failed: { [Error: Command failed: ] killed: true, code: null, signal: 'SIGTERM' }
I20150216-16:08:31.864(-6)? stderr:
W20150216-16:08:31.888(-6)? (STDERR) Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
W20150216-16:08:31.888(-6)? (STDERR)     at Object.Meteor._nodeCodeMustBeInFiber (packages/meteor/dynamics_nodejs.js:9:1)
W20150216-16:08:31.888(-6)? (STDERR)     at [object Object]._.extend.get (packages/meteor/dynamics_nodejs.js:21:1)
W20150216-16:08:31.888(-6)? (STDERR)     at [object Object].RouteController.lookupOption (packages/iron:router/lib/route_controller.js:66:1)
W20150216-16:08:31.888(-6)? (STDERR)     at new Controller.extend.constructor (packages/iron:router/lib/route_controller.js:26:1)
W20150216-16:08:31.888(-6)? (STDERR)     at [object Object].ctor (packages/iron:core/lib/iron_core.js:88:1)
W20150216-16:08:31.888(-6)? (STDERR)     at Function.Router.createController (packages/iron:router/lib/router.js:201:1)
W20150216-16:08:31.888(-6)? (STDERR)     at Function.Router.dispatch (packages/iron:router/lib/router_server.js:39:1)
W20150216-16:08:31.888(-6)? (STDERR)     at Object.router (packages/iron:router/lib/router.js:15:1)
W20150216-16:08:31.888(-6)? (STDERR)     at next (/Users/rglover/.meteor/packages/webapp/.1.1.6.1dih7yh++os+web.browser+web.cordova/npm/node_modules/connect/lib/proto.js:190:15)
W20150216-16:08:31.889(-6)? (STDERR)     at packages/ongoworks:spiderable/spiderable_server.js:131:1

This is after uninstalling the original spiderable package as well as gadicohen:phantomjs.

Sounds like @Volvox may be correct here.

@nate-strauser
Copy link

+1 i'm getting this error also -- but only on modulus - can not seem to get it to happen on localhost, even in production mode - using spiderable and dfischer:phantomjs packages

for what it's worth, all tests of spiderable using curl seem to work just fine

@katywings
Copy link

Having this problem too, pretty anoying. 2h of debugging and no fix found...

@tomwasd
Copy link

tomwasd commented Mar 6, 2015

Just to add that I'm getting this error too on Ubuntu 14.04 on Digital Ocean. Haven't had a chance to look into a solution yet so just a +1 for now!

@cmather
Copy link
Contributor

cmather commented Mar 6, 2015

Does the problem happen with a bare app with no packages except iron router on it and one simple home page route?

It does look like some kind of fiber issue. But I took care to wrap iron router callbacks in Meteor.bindEnvironment so I don't think this is a core iron router issue. Nonetheless it would be good to pinpoint it. Maybe we can change some logic to make it full proof.

On spiderable, there's a lot of other random things that could be happening. When you see a message about phantomjs being killed, it means that phantomjs spun up a virtual browser and tried to hit your url but either an error happened or it timed out (i.e. couldn't reach the url). In both cases you get this arcane looking error. Not clear to me from this thread whether the spiderable / fiber issues are related or not. I.e., does the fiber error happen without spiderable?

@Volvox
Copy link

Volvox commented Mar 7, 2015

@cmather when creating a brand new meteor app with spiderable installed as the only extra package, things work fine. The fiber error occurs as soon as iron router is added.

@GageBachik
Copy link

+1 I have the same error...
Ubuntu with Digital Ocean.

Is there no fixes yet?

@GageBachik
Copy link

if anyone was wondering I was able to get a quick fix up and running by using
ongoworks:spiderable
instead of spiderable

but I'd like to use the official package.

@cmather
Copy link
Contributor

cmather commented Mar 11, 2015

Can someone link to a reproduction with steps. In the initial example I'm not sure if there are routes or if it's failing on initial project creation. Show me a runnable app and I'll see if I can trace it down.

EDIT: We're not having issues with spiderable and iron router with EM which is why I think there might be some other variable here that I'm not seeing.

@katywings
Copy link

Hmmm... My env is Digitalocean / Ubuntu too. Meteor is in a docker and proxied by nginx over ssl. I tried the Spiderable SSL package. I tried opening the http port on the host with direct access to the meteor port and setting ROOT_URL to the http port. Also tried ongoworks:spiderable which did not solve the problem.

@nooitaf
Copy link

nooitaf commented Mar 14, 2015

+1
...and i was wondering about google index ^^
.. ongoworks:spiderable also didn't solve my problem

@tomwasd
Copy link

tomwasd commented Mar 19, 2015

Subtracting my +1

ongoworks:spiderable solved my problem - haven't had time to delve into it in detail but ongoworks' package states 'Uses port as set in meteor port and /tmp/ files instead of /dev/stdin' and as I was using nginx to forward everything to https I'm guessing I may have introduced an issue with using the official spiderable package.

I know ongoworks hasn't worked for others but just wanted to highlight that the exact same error can crop up through no fault of iron router.

@katywings
Copy link

Ty for your feedback. I was already going to make another try with the ongoworks pkg. Will add a new comment with the results later.

@katywings
Copy link

Okay I updated meteor and retried ongoworks which really didnt help... The error stays the same and doesnt anyhow help to fix it self. I bloody hate such troll errors xD

After this problem, I fell in love with blue screens

Maybe it would help if we list our installed packages?

My only next idea would be to dublicate the spiderable and iron router packages and adding verbose logs...

EDIT: MAJOR UPDATE
I duplicated the ongoworks:spiderable package and made some changes. The new package doesnt use phantom js anymore. Instead it will use zombie with its really cool npm integration. I tried it out and it solved all, (happy-town folks!) problems: the problems i had, and I think yours gonna be fixed with it too. No ol child_commands, "bin" thingies, execs and lame :P stdouts will be needed with the incoming changes...

I need to refactor the new package, make tests, more tests and than upload it on atmosphere or so...

Whatsoever: i think: the changes exhibit, that this spiderable issue has nothing really todo with iron-router... The spiderable package seems to be programmed a little bit slugish and its errors are ultra non-verbose.

When the package is out i will inform you guy's ;).

I am really tired, so my english is a bit plunked xD

@Volvox
Copy link

Volvox commented Apr 3, 2015

@katywings any update on that package?

@katywings
Copy link

I cant work on it at the moment. Having the flu :(

@ghost
Copy link

ghost commented Apr 5, 2015

Windows 8.1 also getting this error.

Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
at Object.Meteor._nodeCodeMustBeInFiber (packages/meteor/dynamics_nodejs.js:9:1)
at [object Object]._.extend.get (packages/meteor/dynamics_nodejs.js:21:1)
at [object Object].RouteController.lookupOption (packages/iron:router/lib/route_controller.js:66:1)
at new Controller.extend.constructor (packages/iron:router/lib/route_controller.js:26:1)
at [object Object].ctor (packages/iron:core/lib/iron_core.js:88:1)
at Function.Router.createController (packages/iron:router/lib/router.js:201:1)
at Function.Router.dispatch (packages/iron:router/lib/router_server.js:39:1)
at Object.router (packages/iron:router/lib/router.js:15:1)
at next (C:\Users\MustafaH\AppData\Local\.meteor\packages\webapp\1.2.0\npm\node_modules\connect\lib\proto.js:190:15)
at packages/spiderable/spiderable_server.js:123:1

@jhmacdon
Copy link

jhmacdon commented Apr 7, 2015

+1, having this error on Ubuntu on an EC2 server

@katywings
Copy link

Little Update: I am fixing the last bugs but anyway the new package will follow soon!

Edit: i could fix them, gonna test the new package currently on my DigitalOcean Server, it works here: https://nitropage.com/?_escaped_fragment_=

I will upload the package next weekend i think. Just to get you prepared: it looks like the new browser zombie which replaces phantomjs, needs make, so maybe you can prepare your machine with apt-get install build-essential

@katywings
Copy link

Okay 💃 Announcement Time: the package is finally online, try it out and give me feedback if something doesn't work:
https://atmospherejs.com/lufrai/spiderable2

@olivierpascal
Copy link

+1 for me. ongoworks:spiderable and lufrai:spiderable2 didn't solve the problem.

@katywings
Copy link

Sad to hear :/, whats your environment?

@olivierpascal
Copy link

dev: OSX
preprod/prod: DigitalOcean + Docker + Meteord (ubuntu)

@katywings
Copy link

Kk, but with the package lufrai:spiderable2 did you set the port in the config? Because spiderable needs to know the original port of the meteor server (not the port of nginx or your host or whatever)

@olivierpascal
Copy link

Absolutely :) cf. lufrai/spiderable2#5

@olivierpascal
Copy link

After hours of debugging I've finally find out the cause of this problem.

spiderable: phantomjs failed: { [Error: Command failed: ] killed: true, code: null, signal: 'SIGTERM' } is just a symptom. I had to deploy with --debug to see the real cause, which was due to the package meteor-pages, that use .bind() which is not supported by phantomjs < 2.0.

So removing meteor-pages fix the issue and makes phantomjs works well. But now I have to figure out how to use meteor-pages without make phantomjs 1.9.7 explode (or just upgrade to 2.0)!

Good luck all.

@katywings
Copy link

Did I get you correctly that Meteor-Pages requires phantom? Whats the exactly line of code which fails?

Spiderable2 doesnt use phantomjs!

@olivierpascal
Copy link

Indeed, I was back to spiderable with phantomjs. :) FYI I think it's related to this bug: alethes/meteor-pages#111

@Danappelxx
Copy link

@katywings Your package fixed my issues! I was just about ready to give up after a few hours of debugging. My only complaint is that pages load significantly slower when going through it, but that's not really an issue since all I'm going for is web-crawlers to actually index my website. Thanks!

@thatgibbyguy
Copy link

I have the same error with Digital Ocean running Ubuntu 14.04 and deployed using mup. I have the 5gb droplet for development. Is there a final solution for this issue yet?

@katywings
Copy link

Have you tried lufrai:spiderable2?

@thatgibbyguy
Copy link

@katywings I actually just removed spiderable and added ongoworks:spiderable which has solved my problem on Digital Ocean.

To solve the problem locally what I did was install dfischer:phantomjs.

@pranavgarg
Copy link

I was running into the same, turned out @thatgibbyguy suggestion's meteor add dfischer:phantomjs saved the day for me. Worked with even spiderable package.

@mikkhait
Copy link

I found the issue that was breaking my implementation. Just to be clear, I tried ever suggestion possible in this thread, nothing helped, so I kept looking...

I've rolled back to the version that was working and started digging...

What turns out to be a problem is that one of my "publish" methods was returning false instead of expected array. As soon as I started returning an array, everything was back to normal.

Broken

Meteor.publish('applications', function () {
  if (this.userId) {
    return Applications.find({'user._id': this.userId});
  } else {
    return false;
  }
});

Fixed

Meteor.publish('applications', function () {
  if (this.userId) {
    return Applications.find({'user._id': this.userId});
  } else {
    return [];
  }
});

I hope this saves someone hours in the middle of the night.

@sungwoncho
Copy link
Contributor

I've been commenting out parts of my app to find the culprit, but no success yet. +1

@hellogerard
Copy link

In case it helps anyone, I had two lines that were breaking spiderable with this error:

if not Detector.webgl

and

if not Meteor.user() and not Meteor.loggingIn()

I changed them to the following, respectively, which fixed the error:

if not Detector.webgl and not /PhantomJS/.test(window.navigator.userAgent)

and

if not Meteor.user() and not Meteor.loggingIn() and not /PhantomJS/.test(window.navigator.userAgent)

So I don't know if there's a one-size fits all solution for this one. The error seems to be a generic catch-all in phantomjs.

@katywings
Copy link

Hello hellogerard

Thanks for your info! Yeah its almost impossible to figure out a way to make every possible package environment working ;)

@jancurn
Copy link
Contributor

jancurn commented Oct 31, 2015

I had the same problem. After some digging I found out that Meteor subscriptions were never ready when the app was launched from PhantomJS browser on a production server, therefore Spiderable.isReady() never returned true, PhantomJS kept waiting 15 seconds and then failed disgracefully, throwing the above error. I think PhantomJS might have some problem with the SSL/TLS protocol used in the production environment or maybe all the proxies along the way (our setup is CloudFlare=>AWS ELB=>nginx=>Meteor).

To work around this, I added the following code on the server:

var originalFunc = Spiderable._urlForPhantom;
Spiderable._urlForPhantom = function (siteAbsoluteUrl, requestUrl) {
    var url = originalFunc("http://localhost:8080/", requestUrl);
    console.log("Resolved Spiderable request " + requestUrl + " to " + url);
    return url;
};

where http://localhost:8080/ refers to the local Meteor server URL and not the public-facing ROOT_URL that runs through the proxies and TLS/SSL. It works like a breeze now.

@razvangherghina
Copy link

@jancurn thanks!

@srflp
Copy link

srflp commented Jul 1, 2016

@jancurn thanks! Works like a charm!

@yim1990
Copy link

yim1990 commented Nov 7, 2016

@jancurn You save my life... Thank you

@jremi
Copy link

jremi commented Jun 23, 2017

@jancurn thanks for this snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests