Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Exit code / http error documentation #1502

Closed
Req opened this issue Feb 7, 2014 · 16 comments
Closed

Exit code / http error documentation #1502

Req opened this issue Feb 7, 2014 · 16 comments

Comments

@Req
Copy link

Req commented Feb 7, 2014

When testing I kept getting exit code 1 quite often due to http error 1005 or 1xxx. Is there any documentation on exit codes and http error codes? It seems like exit code 1 usually can be ignored and happens only when something doesn't return 200 or such on the page. But what about the http errors? Http error 1005 doesn't really tell me anything

From looking at https://github.com/wkhtmltopdf/wkhtmltopdf/blob/master/src/lib/utilities.cc it would look to me like anything returning 404 would mean a returncode 2 and 401 would be 3 and anythign else is 1. Error 1005 doesn't sound like any http error I know. If I didn't fail it comes from PdfConverter's httpErrorCode() and there it comes from pageLoader.httpErrorCode(), but that's as far as I got tracing them from the source.

Documentation would be helpful in knowing which errors to ignore, currently it would seem to me like exit codes 0, 1, 2 and 3 can just be ignored quite safely.

@ashkulz ashkulz added this to the 0.12.x milestone Feb 7, 2014
@ashkulz
Copy link
Member

ashkulz commented Feb 7, 2014

Can you submit a pull request for the changes? I'm going to try to track down the HTML header issue over the weekend.

@pflannery
Copy link

I get a similar scenario.
It would be great if we can distinguish between the errors and warnings from the exit code.

This is the output I get for a basic html page that contains a google map injected using js from https://maps.googleapis.com/maps/api/js.

Loading pages (1/6)
Warning: Failed to load https://maps.gstatic.com/cat_js/intl/en_gb/mapfiles/api-3/15/10/{controls}.js (ignore)
Warning: Failed to load https://maps.gstatic.com/mapfiles/transparent.png (ignore)
Warning: Failed to load https://maps.gstatic.com/cat_js/intl/en_gb/mapfiles/api-3/15/10/{stats}.js (ignore)
Warning: Failed to load https://maps.gstatic.com/cat_js/intl/en_gb/mapfiles/api-3/15/10/{util,onion}.js (ignore)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Exit with code 1 due to http error: 1005

The pdf comes out acceptable, it's just the exit code would say otherwise.

👍 for a fix to this

@ashkulz
Copy link
Member

ashkulz commented Feb 10, 2014

Just would like to confirm: was 1005 the only error code that you saw?

@pflannery
Copy link

For me yes, the above is the entire message I got.

@ashkulz
Copy link
Member

ashkulz commented Feb 10, 2014

so you didn't see any other error codes above 1000? looks like I have a fix ready, then...

@xiankai
Copy link

xiankai commented Feb 12, 2014

Just wanted to mention that I got an error code 1203:

Loading pages (1/6)
Warning: Failed to load file:///core/images/close-16x16.png (ignore)
Warning: Failed to load file:///core/images/down-arr-16x16.png (ignore)
Warning: Failed to load file:///core/images/flickr/loading.jpg (ignore)
Counting pages (2/6)                                               
Resolving links (4/6)                                                       
Loading headers and footers (5/6)                                           
Printing pages (6/6)
Done                                                                      
Exit with code 1 due to http error: 1203

I also got a PDF that was fine. The files that failed to load were relative URLs that were pulled in via AJAX, but those were not my concern.

-EDIT- removing the local URLs still resulted in the same error code. Not sure what's the cause now.

Unfortunately, I cannot test this fix as I rely on the PHP Composer distribution at https://github.com/h4cc/wkhtmltopdf-i386, and don't know how to compile the latest version of this.

@ashkulz
Copy link
Member

ashkulz commented Feb 12, 2014

according to the list of errors, 203 is ContentNotFoundError ie an AJAX 404. It would be reported more correctly in the latest commit, but the error would still remain.

@ashkulz
Copy link
Member

ashkulz commented Feb 13, 2014

Binaries for Linux/Windows (32/64-bit) of the latest development snapshot are available, please test whether they work for you. Mac OS X binaries should be available in a day or so.

@npinchot
Copy link
Contributor

Mac OS X binaries are available now as well.

@xiankai
Copy link

xiankai commented Feb 14, 2014

Looks good, getting a Exit with code 1 due to network error: ContentNotFoundError with the latest development snapshot.

@pflannery
Copy link

This is what I now get

Loading pages (1/6)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done

But this still leaves the issue of not being able to determine between errors and warnings. The test PDF I ran didn't render the map just like previous version of wkhtmltopdf. Before I had warnings messages and an exit code of 1.

I would like to be able to determine if there were warnings or errors in the exit code.

@ashkulz
Copy link
Member

ashkulz commented Feb 18, 2014

@pflannery: look at the --load-error-handling and the --load-media-error-handling options and see if they help you out.

@Req
Copy link
Author

Req commented Feb 21, 2014

My original issue was with the documentation. On wkhtmltopdf.org, the manual or somewhere I wanted to see a table explaining the exit codes. Something like this:

EditCode Explanation
0 All OK
1 PDF generated OK, but some request(s) did not return HTTP 200
2 Could not something something
X Could not write PDF: File in use
Y Could not write PDF: No write permission
Z PDF generated OK, but some JavaScript requests(s) timeouted
A Invalid arguments provided
B Could not find input file(s)
C Process timeout

That would be very very useful documentation, so that the users could check this when they don't get exit(0). I would use this too, because if I get a 404 or something like that for some images or whatnot, I still want the PDF to be generated and I will be happy to serve it.

I don't have a pull request because I have no idea how to do this, where to do this or even how to do pull requests - sorry! Maybe they coyld be in README.md and wkhtmltopdf.org and the manual all three?

@ashkulz
Copy link
Member

ashkulz commented Feb 22, 2014

@Req: a lot of times multiple situations could be possible, also I am not sure that it would be possible to report all of them. On the documentation front, I agree -- there is quite a lot that can be improved and will happen as time permits. The website is in the repository wkhtmltopdf.github.io -- if someone submits a PR, it will auto-update the website once accepted.

@omrqs
Copy link

omrqs commented Mar 2, 2017

This error occurs when url are defined as //url... in place of https://url....
Keep the protocol.
wkhtmltopdf try find double slash as local path...

Solved for me.

@naaaargle
Copy link

I'm having a similar issue where I'm seeing exit code -15 and can't find what it means anywhere. Anyone have any insight?

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

No branches or pull requests

7 participants