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 errors #1150

Open
aldeed opened this issue Dec 30, 2014 · 16 comments
Open

spiderable errors #1150

aldeed opened this issue Dec 30, 2014 · 16 comments

Comments

@aldeed
Copy link

aldeed commented Dec 30, 2014

Seeing this error with every spiderable request using latest iron:router (1.0.6).

spiderable: phantomjs failed: null 
stderr: 
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 (/mnt/data/2/node_modules/connect/lib/proto.js:190:15)
    at packages/spiderable/spiderable_server.js:123:1

Is it something in one of my router hooks? What's the best way to debug this?

@joernroeder
Copy link

same error here…

@joernroeder
Copy link

@aldeed did you find a fix for this issue?

@aldeed
Copy link
Author

aldeed commented Jan 23, 2015

No. Removed spiderable for now.

@timothyarmes
Copy link

Spiderable was working on my local server. I've just uploaded to a digital ocean server using mup (with the option to install PhantomJS set to true) and I'm also seeing this error.

Can anyone help solve this?

@marcelpanse
Copy link

Same issue here..

@dasmodel
Copy link

Anyone figured this out yet? Or have a workaround?

@marcelpanse
Copy link

Eventually it didn't have much to do with iron router, but with some client-side javascript errors that crashed phantomjs, make sure there are no client-side javascript errors whatsoever.

@dasmodel
Copy link

Strange...no client-side errors for me at all but still the same issue!

@dasmodel
Copy link

Ok I found what I think was causing the issue for me — it looks like when I take away all my external <script> tags in my <head>, the error disappears. But that means I'm unable to load typekit, google analytics, etc. which is problematic...

@fabien-h
Copy link

I ran into the same problem and it drove me crazy. Removing the <script> tags in the header of my html solve the problem. I have typekit and ga too. You just have to add this in your app.js (or whatever fires first) :

( function ( i, s, o, g, r, a, m ) {console.log( arguments ); i[ 'GoogleAnalyticsObject' ] = r; i[ r ] = i[ r ] || function () {( i[ r ].q = i[ r ].q || [] ).push( arguments ); }, i[ r ].l = 1 * new Date(); a = s.createElement( o ), m = s.getElementsByTagName( o )[ 0 ]; a.async = 1; a.src = g; m.parentNode.insertBefore( a, m ); } )( window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga' );
ga( 'create', 'xxx', 'auto' );
ga( 'send', 'pageview' );

// Load the fonts
$.getScript( '//use.typekit.net/xxx.js', function () {
    try {
        Typekit.load();
    } catch ( e ) {}
} );

@fabien-h
Copy link

Well.. actually, it did not solved my problem. Back to crazy :(

Everything used to work perfectly fine until two weeks ago (the application is deployed on modulus, works fine in local)

@dasmodel
Copy link

@fabien-h I tried out your solution with several scripts moved from my <head> tag into my compatibility folder. It is now working with GA, heap analytics, and zopim, but Typekit seems to be the real issue here. Once I remove typekit, escaped fragment seems to work without any issues.

@fabien-h
Copy link

hum, that will be a problem...

Do you know how to check if the page is rendered by the client or by phantom js ?

@thomasspiesser
Copy link

seeing the same error. even when i remove everything from the <head> tag. earlier on an @import statement in my css caused the same error btw, but also on localhost with --production. the site is deployed on myApp.meteor.com. did anyone manage to solve the issue yet? on a side note, could this be related to the fiber issue #1192 ?

@louis49
Copy link

louis49 commented Oct 13, 2015

Seems working on my config with iron:router@1.0.12

@bshamblen
Copy link

I'm running into the same issue. In my particular case I'm using both the spiderable package (for rendering the majority of the pages on my site to web crawlers), and the meteorhacks:ssr package in conjunction with the iron-router where: 'server' option (for rendering two specific routes that must be rendered on the server every time).

I followed the code back through the stack trace and it looks like an issue in the RouteController.lookupOption function. I believe the issue is that, for some reason, the CurrentOptions environmental variable is not set when the lookupOptions function is called. So, when the following line is executed, an error is thrown:

var opts = CurrentOptions.get();

I copied an pasted all of the code for the RouteController.prototype.lookupOption function into my project and wrapped the code that checks for the current options in an if statement to check to see if the CurrentOptions variable is undefined, and it no longer throws the fibers error.

// see if we have the CurrentOptions dynamic variable set.
if (typeof CurrentOptions !== 'undefined') {
    var opts = CurrentOptions.get();
    if (opts && _.has(opts, key))
        return opts[key];
}

I still get the following error at the cli, but the page renders:

spiderable: phantomjs failed at http://localhost:3000/ns: { [Error: Command failed: ] killed: true, code: 1, signal: null }

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

9 participants