[api-minor] Ensure that PDFDocumentProxy.hasJSActions
won't fail if MissingDataException
s are thrown during the associated worker-thread parsing
#13234
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With the current implementation of
PDFDocument.hasJSActions
, in the worker-thread, we're not actually handling not-yet-loaded data correctly. This can thus fail in two different ways:PDFDocument.fieldObjects
getter (and its helper method), while it may return a Promise, still fetches all of its data synchronously and it can thus throw aMissingDataException
during parsing.Catalog.jsActions
getter, which is completely synchronous, can obviously throw aMissingDataException
during parsing.If either of these cases occur currently, the
PDFDocumentProxy.hasJSActions
method in the API can either return a rejected Promise (which it never should) or possibly "hang" and never resolve.Please note: While I've not yet seen this error in an actual PDF document, it can happen during loading if you're unlucky enough with e.g. the structure of the PDF document and/or the download speed offered by the server.
This patch is thus based on code-inspection and on manually throwing a
MissingDataException
on the first access ofCatalog.jsActions
to simulate this situation.Finally, this patch adds a couple of API unit-tests for this (since none existed).