benjick / stripe-meteor

A Meteor package containing Stripe.js, Node-Stripe, and Stripe Checkout.
https://atmospherejs.com/benjick/stripe
3 stars 1 forks source link

Stripe errors in spiderable package #3

Open BradRyan opened 9 years ago

BradRyan commented 9 years ago

I've been having spiderable issues when testing the '?_escapedfragment=' (similar to those here: https://github.com/iron-meteor/iron-router/issues/1192) while hosting on Modulus. I was attempting to fix them by using ongoworks:spiderable package. The error I was getting on the server is resolved, but now I'm seeing some other strange issues.

Using the ongoworks:spiderable package on the server, the following shows up inside my browser window's tags. I'm concerned this might actually show up in crawler results as I can see it on my browser window.

ReferenceError: Can't find variable: Stripe

  http://localhost:8080/6be5bf8c35549ee74d21715c535054213bed89d5.js:318
  http://localhost:8080/6be5bf8c35549ee74d21715c535054213bed89d5.js:3
  http://localhost:8080/6be5bf8c35549ee74d21715c535054213bed89d5.js:3

Using the ongoworks:spiderable package on localhost (http://localhost:3000/?_escaped_fragment_=) I get the following errors in my browser console.

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://localhost:20677') does not match the recipient window's origin ('http://localhost:3000').Stripe.isDoubleLoaded.H.stack.PostMessageTransport.g.onDOMReady @ (index):2(anonymous function) @ (index):2i @ (index):2

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://localhost:20677') does not match the recipient window's origin ('http://localhost:3000').window.onload @ channel.html?stripe_xdm_e=http%3A%2F%2Flocalhost%3A20677&stripe_xdm_c=default890866&stripe_xdm_p=1:25

Any ideas?

BradRyan commented 9 years ago

FYI, the errors when using the packages dfischer:phantomjs and spiderable I don't get any errors locally, but when running on the server I am seeing the following error when including the escaped fragment.

spiderable: phantomjs failed: { [Error: Command failed: Can't open '/dev/stdin'
] killed: false, code: 255, signal: null } 
stderr: Can't open '/dev/stdin'

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/app/node_modules/connect/lib/proto.js:190:15)
    at packages/spiderable/spiderable_server.js:123:1
    at ChildProcess.exithandler (child_process.js:652:7)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)
Found package.json: ./package.json
Start script specified in package.json: node main.js
Initializing Node.js 0.10.33
Now using node v0.10.33
Running command: npm start
benjick commented 9 years ago

How are you using the package?

On Tue, Jul 7, 2015 at 11:36 PM, BradRyan notifications@github.com wrote:

FYI, the errors when using the packages dfischer:phantomjs and spiderable I don't get any errors locally, but when running on the server I am seeing the following error when including the escaped fragment.

spiderable: phantomjs failed: { [Error: Command failed: Can't open '/dev/stdin' ] killed: false, code: 255, signal: null } stderr: Can't open '/dev/stdin'

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/dynamicsnodejs.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/app/node_modules/connect/lib/proto.js:190:15) at packages/spiderable/spiderable_server.js:123:1 at ChildProcess.exithandler (child_process.js:652:7) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:756:16) at Process.ChildProcess._handle.onexit (child_process.js:823:5) Found package.json: ./package.json Start script specified in package.json: node main.js Initializing Node.js 0.10.33 Now using node v0.10.33 Running command: npm start

— Reply to this email directly or view it on GitHub https://github.com/benjick/stripe-meteor/issues/3#issuecomment-119349801 .

BradRyan commented 9 years ago

The stripe package? At the time the error is thrown I'm not using it at all. It's just being loaded with the recommended startup code. In my app, I'm using Stripe Connect, and other miscellaneous charge / refund features. Note that I don't normally get this error, but when I type in ''www.mywebsite.com?_escapedfragment='', the error appears.

This didn't occur with the regular spiderable package, but the server threw exceptions that would allow the web spiders to crawl my site.

benjick commented 9 years ago

So you're not using the package?

Could you do if(typeof(Stripe) !== 'undefined') { Stripe.set.... }?

BradRyan commented 9 years ago

Thanks for the suggestion... Where would you recommend I place that code exactly?

BradRyan commented 9 years ago

nevermind... I get it!

BradRyan commented 9 years ago

I get the same error that I had previously on the local machine. I don't think the startup code is run when using ?escaped_fragment=. I put a log in front of the setPublishable key and I'm not seeing it. Perhaps because it's not initalized it throws the error becouse of stripe functions on the server?

This error is strange though:

Stripe.isDoubleLoaded.H.stack.PostMessageTransport.g.onDOMReady
benjick commented 9 years ago

Strange, are you doing setPublishableKey on client only or both?

BradRyan commented 9 years ago

I've been setting it in the client only.

adamwong246 commented 8 years ago

+1

BradRyan commented 8 years ago

@adamwong246 FYI, I ended up pulling this out of my client code and just establishing the key on my calls. Definitely messed up my SEO for a bit.