-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Enable the missing PDF unit test for the API in NodeJS #9791
Comments
I am working on it |
@timvandermeij Do you think using pdf.js/src/display/node_stream.js Line 31 in 7e13977
and throwing a MissingPDFException if res.statusCode===404 || res.statusCode === 0 && /^file:/.test(sourceUrl) would help?
|
I think the problem is that you're requesting the file twice then: once for this check and once to actually load the file. It's probably better to handle this in the spot where we're actually attempting to load the file. Perhaps it would help to enable the test locally, see where it breaks and backtrace from there. |
The objective is to remove https://github.com/mozilla/pdf.js/blob/master/test/unit/api_spec.js#L166-L170 by fixing up
src/display/node_stream.js
to throwMissingPDFException
when a PDF file is not found. Right now, this file is not handling errors in a consistent or even correct way compared withsrc/display/network.js
andsrc/display/fetch_stream.js
. Using thecreateResponseStatusError
utility function might not make much sense in a Node.js environment. However, at the very least it seems thatMissingPDFException
orUnknownErrorException
when we cannot tell that a PDF file is missing should be thrown manually. As is, the API (i.e.,getDocument
) is not returning the expected errors when loading fails in Node.js environments (as evident from this pending API unit test).The text was updated successfully, but these errors were encountered: