superstringsoftware / observatory

Powerful, yet easy to use, logging, monitoring and application management package for Meteor framework. Some docs below, for details -
http://observatoryjs.com
Other
110 stars 11 forks source link

Javascript errors when using spiderable with observatory #30

Open rantav opened 11 years ago

rantav commented 11 years ago

Hi, it seems that there are errors when adding spiderable to a project that uses observatory. More specifically, running phantomjs with observatory. Spiderable uses phantomjs. Opening a meteor site that uses observatory with phantomjs results in js errors. TypeError: 'undefined' is not a function (evaluating 'this._emitWithSeverity.bind(this,o)')

I can't say I found the exact reason, but repro seems to be 100%. Maybe it's related to some user agent magic or something in phantomjs's javascript agent or the way it handles network connections or something, but anyway I get the error when deploying a simple meteor site and adding only two packages: spiderable (which before adding observatory works) and then observatory.

$ mrt create test
$ cd test
$ mrt add spiderable
$ mrt deploy testing123xxx.meteor.com

$ curl http://testing123xxx.meteor.com/?_escaped_fragment_=
>> OK (page gets rendered)

$ mrt add observatory
$ curl http://testing123xxx.meteor.com/?_escaped_fragment_=
>> timeout. (15 secs later we get a JS bare page instead of an HTML page)

Now writing a phantomjs script and running it shows the actual JS errors

Here's the phantomjs script (copied from spiderable):

var url = "http://testing123xxx.meteor.com/";
var page = require('webpage').create();
page.open(url);
setInterval(function() {
var ready = page.evaluate(function () {
  if (typeof Meteor !== 'undefined'         &&
      typeof(Meteor.status) !== 'undefined'         &&
      Meteor.status().connected) {
        Deps.flush();
        console.log(5);
      return DDP._allSubscriptionsReady();
}
return false;
});
if (ready) {    var out = page.content;
out = out.replace(/<script[^>]+>(.|\n|\r)*?<\/script\s*>/ig, '');
out = out.replace('<meta name="fragment" content="!">', '');
console.log(out);
phantom.exit();
}}, 100);

And now:

$ phantomjs my-phantom-script
TypeError: 'undefined' is not a function (evaluating 'this._emitWithSeverity.bind(this,o)')

I have also tried this with mrt deploy --debug and the same error happens.

Again, I don't see the direct connection (in a regular browser that's OK) but in phantomjs I definitely see the errors and it's 100% repro.

JohnAllen commented 10 years ago

What was the cause of this? I'm getting something similar, locally that is. Testing Phantom + Spiderable before pushing to production.