Sometimes getting browser.statusCode=undefined. Is there a timing issue ?

212 views
Skip to first unread message

Soumendra Daas

unread,
Feb 26, 2014, 10:04:01 PM2/26/14
to zomb...@googlegroups.com
Hi,

I am new to ZombieJS, and perhaps I have not fully understood how browser.visit() works. When I try to visit a URL that contains multiple redirects, I sometimes end up with browser.StatusCode = undefined. Since this is happening intermittently, I suspect it is some kind of a timing issue. Can someone help me understand what I am doing wrong. I am using Zombie 2.0.0-alpha29 Here is my code

var Browser = require("zombie");
var assert = require("assert");

var browserOptions = {
        debug : true,
userAgent : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36"
};

var browser = new Browser(browserOptions);
browser.visit(url, function(){
console.log("Status Code = " + browser.statusCode + ", success = " + browser.success);
});

Most of the time I get the normal/correct response, which is


But sometimes I get the following

Zombie: Opened window http://mobile.twitter.com 
Status Code = undefined, success = false
Zombie: Event loop is empty
Zombie: GET http://mobile.twitter.com/ => 200

BTW, FWIW I am working out of India - ping to mobile.twitter.com takes ~400ms.

Regards

SD

Assaf Arkin

unread,
Feb 26, 2014, 10:06:10 PM2/26/14
to Soumendra Daas, zomb...@googlegroups.com
Check out it you’re getting an error. The first argument to the callback would be the error.

--
You received this message because you are subscribed to the Google Groups "zombie.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zombie-js+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

–––––

Subscribe to Weekend Reading, a newsletter about design, code, startup life and the occasional odd

Soumendra Daas

unread,
Feb 26, 2014, 11:20:31 PM2/26/14
to zomb...@googlegroups.com, Soumendra Daas
Thanks Assaf. I looked at the first arg to the callback - it shows up as "undefined" in either case.

Daas

Assaf Arkin

unread,
Feb 27, 2014, 11:10:20 AM2/27/14
to Soumendra Daas, zomb...@googlegroups.com, Soumendra Daas
It should definitely not call the callback unless there’s an error, or it’s done processing (logs event loop empty). So something is not working correctly.

Soumendra Daas

unread,
Mar 18, 2014, 6:21:16 AM3/18/14
to zomb...@googlegroups.com, Soumendra Daas
Hi Assaf,

Any thoughts on how to debug this further ? 

SD

Assaf Arkin

unread,
Mar 18, 2014, 2:48:14 PM3/18/14
to Soumendra Daas, zomb...@googlegroups.com, Soumendra Daas
Beyond the DEBUG=true, you have to either single trace, or litter the source code with console.log statements.
 

For more options, visit https://groups.google.com/d/optout.

Mike Merritt-Holmes

unread,
May 9, 2014, 6:17:45 AM5/9/14
to zomb...@googlegroups.com, Soumendra Daas
Did this ever get resolved as I am seeing statusCode undefined too.
Reply all
Reply to author
Forward
0 new messages