This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Return error status code if document fails to render in MAX_DELAY limit?

centi wrote on 2020-04-14:
Hi,

I'm using the API option "wait_for_element" and in some cases the rendering of my page takes longer, than the MAX_DELAY limit for my plan (2s). But the API returns 200 with a "bad" PDF (the page did not have enough time to render), so I am not able to distinguish a good PDF from a bad one due to the time limit.

Is there any way that the API could return an error status code when the time limit is exceeded? Something like the parameters "fail_on_main_url_error" or "fail_on_any_url_error". Maybe "fail_on_max_delay"?

Thanks.

Ivan
support wrote on 2020-04-14:
Hi Ivan,

API should fail if the element used in wait_for_element is not found. It returns 200 if it's found.
Please try to use wait_for_element or javascript_delay, not both.
centi wrote on 2020-04-14:
Thanks for your reply.

And how does it fail? With the status "458 Conversion Time Exceeded" or "476 Element Not Found"?
support wrote on 2020-04-14:
wait_for_element fails with 476 error if the element is not found:
-- https://pdfcrowd.com/api/status-codes/#status-476
centi wrote on 2020-04-14:
Ok, I get that. But what if the element is not found, because it couldn't be rendered fast enough to fit into MAX_DELAY time? Does it then end with 458?
support wrote on 2020-04-14:
If the element is not found during MAX_DELAY period, error 476 is returned. If the page has slow construction (e.g. due to slow async JS calls), we can provide a custom API license with the increased MAX_DELAY parameter. If you are interested in this option, please contact us on support@pdfcrowd.com with your Pdfcrowd username.


Error 458 is returned if the whole conversion does not finish in time limit for a single conversion (the limit is 60 seconds now).


I'd suggest you to enable debug log by setDebugLog to see loading speed and add some debugging messages to your JS to see how your page is processed.

e.g.
console.log('my start ' + new Date());
... do some stuff ...
console.log('my end ' + new Date());