VASTParser and failed resolving leading to resolved promises
mseeley opened this issue Β· comments
Hello there π. You all have done a really considerate job writing clean code and documentation. It's very quick to read+comprehend. π
I'm looking at bypassing VASTClient#get()
so that we can control which Ad
is resolved. The resolveAll
behavior describes resolving the first ad or all ads. Resolving all can definitely be slow, I'd don't believe we can depend on the first Ad
being the proper one. Instead I'd like to identify the first ad pod or first standalone ad before resolving. In our usages, any work done to resolve Ad 1 is unnecessary until we know that the ad pod resolution failed.
When VASTClient#get()
calls into VASTParser#getAndParseVAST()
it handles promise resolution and rejection. Internally VASTParser#getAndParseVAST()
links to other internal promises including ones from VASTParser#resolveWrappers()
. It's this method that I would really appreciate context.
When the Wrapper
cannot resolve to an InLine
the resolveWrappers
method resolves its Promise
after augmenting the ad
object with error information. The Wrapper
resolution has failed, why is it that the Promise
isn't rejected?
Replacing the return Promise.all(resolveWrappersPromises)
with Promise.allSettled
would allow the parsing to semantically reject.
But, bigger question, VASTClient#get()
or VASTParser#parseVAST()
returns 1:N resolved and unresolved (resolved with error) ads. Is it suggested that clients teach their resolve handling to determine if each ad has resolved correctly and substitute another from the buffet? If so, in which situations would the VASTParser#parseVAST()
promise be expected to reject?
Thanks a lot for you time + input.
Best regards. π
I missed the completeWrapperResolving
activity that filters out ads with an error code. Apologies for my oversight.
We'll make sure to handle a get or parse returning an empty response.ads
array to handle cases where there were no ads or completeWrapperResolving
filtered them all out.
Hi, just to add more information, yes resolveAds
and resolveWrappers
will always resolve, regardless if an error occurred. The only time parse
or parseVAST
could fail is if we get an Invalid VAST XML Document here.