troubles with facebook javascript #11156

Open
erikgardman opened this Issue Mar 21, 2013 · 8 comments

5 participants

@erikgardman

Hello

I am trying to open the page of facebook group and getting a lot of javascript errors randomiously.

I.e i'm tried first time and all is OK - page is loaded without errors, my evaluated javascript on page work success

Repeat opening and all is OK too.

Repeat third and got in console:

TypeError: 'undefined' is not a function (evaluating 'l.bind(this,s)')

http://static.ak.fbcdn.net/rsrc.php/v2/yV/r/kGH3jesJx8K.js:20 in k
http://static.ak.fbcdn.net/rsrc.php/v2/yV/r/kGH3jesJx8K.js:20
http://static.ak.fbcdn.net/rsrc.php/v2/yV/r/kGH3jesJx8K.js:20
http://static.ak.fbcdn.net/rsrc.php/v2/yV/r/kGH3jesJx8K.js:21
ReferenceError: Can't find variable: Bootloader

http://www.facebook.com/groups/304945386299933/members:11
Error: Requiring unknown module "ServerJS"

http://static.ak.fbcdn.net/rsrc.php/v2/yV/r/kGH3jesJx8K.js:20 in j
http://www.facebook.com/groups/304945386299933/members:13
ReferenceError: Can't find variable: $

http://www.facebook.com/groups/304945386299933/members:13
ReferenceError: Can't find variable: Bootloader

http://www.facebook.com/groups/304945386299933/members:14
Error: Requiring unknown module "InitialJSLoader"

http://static.ak.fbcdn.net/rsrc.php/v2/yV/r/kGH3jesJx8K.js:20 in j
http://www.facebook.com/groups/304945386299933/members:16
ReferenceError: Can't find variable: Bootloader


page.open(url, function (status) { }); -- status can be a 'fail' or success..

What can it be?
It seems as not all javascript files is loaded.
How to load it all with phantomjs?

@erikgardman

also:

"When the content is GZIPed, then PhantomJS will sometimes throw an "$ is undefined" exception but sometimes work correctly. When the content is not GZIPed, then PhantomJS will work correctly."

http://code.google.com/p/phantomjs/issues/detail?id=930

I've tried to add customHeaders, but no result:

var page = require('webpage').create();

page.customHeaders = {
'Accept-Encoding': 'identity',
};

When loading is success and js is workng, we can see that this resorses is loaded: http://pastebin.com/FSiNv7tv

When loading is failed - phantomjs load only first 4-5 resources from this list.

Updated: Description: Host static.ak.fbcdn.net not found

@erikgardman

So, problem solved.

If custom user-agent is set (over page.settings.userAgent or page.customHeaders, no difference) -- facebook resources loaded partially 90% times.

When i remove setting up custom user-agent - all start work correctly 100% times.
What the hell =\

@ariya ariya closed this Mar 22, 2013
@standpat

Why is this closed? This still affects 1.9

@ariya
Owner

I thought it was just user agent problem. Reopening.

Also, any further details will be appreciated. Otherwise, it's hard to understand what the problem is. Refer to the Troubleshooting section on the wiki to provide more detailed info.

@ariya ariya reopened this Mar 25, 2013
@erikgardman

Which version of PhantomJS are you using? Tip: run 'phantomjs --version'.
1.9.0 (development)

What steps will reproduce the problem?

  1. add handler

page.onResourceReceived = function (request) {
console.log('[res]<-- #' + request.id + ' ' + request.url);
};

  1. set user-agent:

var page = require('webpage').create();

// first method:
page.customHeaders = {
'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:18.0) Gecko/20100101 Firefox/18.0', -- все идет по пизде
};

// second method:
page.settings.userAgent = "Mozilla/5.0 (Windows NT 6.1; ru-ru) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17";

  1. open https://www.facebook.com (page.open(url))

What is the expected output? What do you see instead?

70% times onResourceReceived show only 4-5 first resouces of the page => all javascript on facebook page does not work and generating a lot of error messages.
In other case, phantomjs load 100% resources (20-30 elements) and all works fine.

Which operating system are you using?
Linux arch, 32 bit
Linux my_host 3.7.8-1-ARCH #1 SMP PREEMPT Fri Feb 15 04:14:33 EET 2013 i686 GNU/Linux

Did you use binary PhantomJS or did you compile it from source?
Compiled from source

Please provide any additional information below.
Without setting user-agent all works correctly always.

@Vitallium
Collaborator

It's Facebook's optimizations. Facebook use the user-agent to determine browser and its possibilities.
If you set any other user-agent (IE7/8, ...), you will see, that all work fine.
We can't fix it.

@JamesMGreene
Collaborator

I've actually seen the same issue as quoted from #10930 related to compression (compressed via IIS web server) when opening pages in Chrome and Safari (on Windows 7 64-bit). As such, I would guess it's a combination of a WebKit bug/deficiency plus whatever "smart" UA-sniffed compression algorithm is being used thinking that WebKit is more capable than it actually is.

I had to disable IIS compression and handle it myself to resolve my issue.

@ariya
Owner

We need to establish a good practice in reporting issues like this. We simply can not keep every single issue "it does not work with FooBar site". There are millions web sites out there and sometimes the problem is with the upstream library we use (QtWebKit) and not PhantomJS own code.

Unless there is a proper reduced test case, not much we can do in that regard. Perhaps this is a good time to kickstart such a discussion in the mailing-list.

@yuxel yuxel referenced this issue in sonsuzdongu/get-http-resources.js Apr 19, 2013
Closed

Facebook'ta çeşitli uyarılar veriyor #1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment