Open aral opened 8 years ago
Update: It definitely doesn’t do it for every site (e.g., works for google.com). In case it helps: if there a redirects, I seem to be getting multiple copies of the error on some sites. e.g., with @bmcminn’s fork:
./electron-har -A IPHONE_6 --debug -o latest.har http://forbes.com
Gives me:
An attempt to generate HAR resulted in error code -3. (error codes defined in http://src.chromium.org/svn/trunk/src/net/base/net_error_list.h) An attempt to generate HAR resulted in error code -3. (error codes defined in http://src.chromium.org/svn/trunk/src/net/base/net_error_list.h)
Hmm… and, oddly, the file is written out correctly despite those errors for forbes.com but not for cultofmac.com.
Curiouser & curiouser :)
I ran into this issue on certain requests I was testing...
The curious part is the documentation around erorr code -3
. I don't see how a user action caused this error.
I just tested this with my fork, where http://cultofmac.com
results in a server 301
redirect to http://www.cultofmac.com
, however when I tried accessing http://www.cultofmac.com
directly, the page responds with 200
, but error code -3
still gets flagged. Not sure what chromium is trying to do here but it does seem odd.
$ bin/electron-har http://cultofmac.com --debug
An attempt to generate HAR resulted in error code -3.
(error codes defined in http://src.chromium.org/svn/trunk/src/net/base/net_error_list.h)
$ bin/electron-har http://www.cultofmac.com --debug
An attempt to generate HAR resulted in error code -3.
(error codes defined in http://src.chromium.org/svn/trunk/src/net/base/net_error_list.h)
EDIT: I found other websites that have a 301 redirect on page load and still generate a HAR file correctly.
http://microsoft.com > 301 > http://www.microsoft.com
http://yahoo.com > 301 > https://www.yahoo.com
So this doesn't seem super unique to 301 redirects. Something else is at work.
Alright, a bit more digging. The event did-fail-load
which is used to initialize har-generation-failed
yields a bit more information. Specifically in regards to the http://cultofmac.com
HAR generation, it has a problem with this specific request: https://cm.g.doubleclick.net/push?client=ca-pub-9678236949631652&srn=gdn
This request errors on account of a 204 response (no content).
I'm thinking the conditional for the bw.webContext.on('did-fail-load'...
handler is too generic which is causing a false positive fail response: https://github.com/shyiko/electron-har/blob/master/src/electron-har.js#L102
Commenting out the conditional allows the HAR file to generate correctly.
@shyiko, was this conditional defined to exit the process if the actual page request failed? because it seems the did-fail-load
event fires for any failed request initialized by the page. From what I can see it may be necessary to add a wrapper conditional to see if the hostname
partial for the did-fail-load
callback url
argument matches the URL hostname
partial we passed to electron-har
.
Oddly enough, Windows 7 Pro 64-bit doesn't experience this issue... more testing is needed :toilet:
Subsequent requests do fail however...
Came up with a temporary fix until the Electron issue #5013 linked above plays out. Pretty sure this is a separate issue considering we would need the response object of the request to determine what the problem was and potentially filter out the failure depending on the status code.
https://github.com/bmcminn/electron-har/blob/psuedo-mainFrame-test/src/electron-har.js#L213-L222
Where it falls short is if some domain asset responded 204
, the problem would crop up again...
it has a problem with this specific request: https://cm.g.doubleclick.net/push?client=ca-pub-9678236949631652&srn=gdn
What? Advertising breaking the web, unheard of! ;P </sarcasm>
Thank you so much for digging in and for the temporary fix. I only just found electron-har yesterday and haven’t worked previously with Electron but my goal, if we can integrate this into our workflow, is to dig into the codebase and try to help out going forward :)
Alright, have some details that I'm documenting here for further testing, but it's a start :P
On OS X, latest El Capitan, using zsh and the electron-har installed via
When I first tried:
It worked, and I got the HAR output to stdout.
Second time + all subsequent attempts, I’m getting:
According to https://src.chromium.org/svn/trunk/src/net/base/net_error_list.h:
Any ideas?