-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled reject Error: Failed to load url
when using SlimerJS
#180
Comments
Please run again as |
My internet went down 😣 and in that time I started getting somewhere. Taking the first part of the stack trace:
We'll head to return self.ready = HorsemanPromise.try(function checkStatus() {
if (status !== 'success') {
var err = new Error('Failed to load url');
return HorsemanPromise.reject(err);
}
}) From there we can see the error is only thrown if
A test with logging the value of [ 'success', 'about:blank', false ] As a result I've temporarily changed the condition as to when the error is thrown to: if (status !== 'success' && status[0] !== 'success') {
// ... |
I believe that the callback is supposed to be called with 3 arguments, not one argument that is an array. Perhaps there is a bug in node-phnatom-simple (or horseman) causing the arguments to be wrong. |
Ahh I see. I'll keep my temporary workaround until baudehlo/node-phantom-simple#133 is resolved. Thanks again for your assistance @awlayton! |
Hi, @awlayton! One more issue regarding this A small pre-history. I have a QA-automation tool based on the Horseman. Before Horseman 3 I used only let lastError
horsemanInstance.on('resourceError', (err) => {
lastError = err
})
horsemanInstance.on('resourceReceived', (err) => {
const err = lastError
// ...check the error and maybe fire a lib-level error...
lastError = null
}) I didn't really like it, but it was straight-forward and seemed robust. The key part was not treating However, Horseman 3 presents a solid system of error handling via promises rejections which is a good move to me. However, actions like Therefore, I need to silence all this errors and continue using my old mechanism to filter out request errors, which looks terrible (empty My point is this exception is quite useless without any details. While promise-rejection-style-of-error-handling is a very good way, it's still not usable enough. So, I see three options now:
I'm aware that this error gets thrown at the callback on Thanks! |
Number 1 sounds good @flashhhh, but I am not sure how horseman could go about improving the exceptions. If you have an idea it would be great if you could submit a PR, or maybe just open a new issue for this improvement and give me detail as to how to go about implementing it. |
I'm having the same issue but with PhantomJS. Even I run the default example: const Horseman = require('node-horseman');
const users = ['silver_no_tsuki'];
users.forEach((user) => {
const horseman = new Horseman();
horseman
.open(`http://twitter.com/${user}`)
.text('.ProfileNav-item--followers .ProfileNav-value')
.then((text) => {
console.log(`${user}: ${text}`);
})
.close();
}); It throws |
hey @minhchu I think it'll be best to create a separate issue for the problem you are facing. This thread will be tracking the issue specifically caused by using SlimerJS with Horseman. I'll be changing the title of this thread to reflect this as well 😄 |
Unhandled reject Error: Failed to load url
when using SlimerJS
I just gave a quick test with the code you have in your comment and was unable to reproduce the issue you're facing. |
I cannot reproduce either @minhchu. When I run it I get this output:
Are you sure it didn't actually fail to get the URL? Maybe you just couldn't reach Twitter. |
@winghouchan thanks for your advice. |
What makes you think this is actually a bug @minhchu? Failing to fetch a URL really can happen. Are you sure it's not your network or something? |
sorry if I misunderstand the meaning of |
A bug is if the software does not work as expected, but your network not working as expected would not be a bug (but it is a problem). If there is a bug, this sort of thing is most likely caused by PhantomJS, not horseman. |
This is the error I got when run
Here is horseman.js: var Horseman = require('node-horseman');
var horseman = new Horseman();
horseman
.userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0')
.open('https://www.google.com/search?site=&tbm=isch&source=hp&biw=1366&bih=640&q=moon')
.screenshot('example.jpg')
.close(); But when I run var page = require('webpage').create();
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0';
page.open('https://www.google.com/search?site=&tbm=isch&source=hp&biw=1366&bih=640&q=moon', function(status) {
console.log("Status: " + status);
if(status === "success") {
page.render('example.png');
}
phantom.exit();
}); So I guess the problem from horseman ? |
Hey @minhchu this definitely deseveres a new thread. I was able to reproduce the case you posted above. Also please consider posting all the output, not just the lines describing the error because the lead-up to the error is also very important. |
See [johntitus#180](johntitus#180) for the bug report and information on the workaround.
Closing since this is a node-phantom-simple issue and not a horseman one. See baudehlo/node-phantom-simple#147 for my proposed fix, if you care. |
When using Horseman with SlimerJS the following error is returned:
The following test case will reproduce it:
The text was updated successfully, but these errors were encountered: