httpClient waitForComplete returns before the response is populated when waiting times are high. Is there a maximum time that we can wait ?
Good Question!
I guess you would want to know two things:
Unfortunately, I don't believe this is documented. The good news is, I can tell you the answer.
As for the first question, regarding the default wait time. The httpClient.waitForComplete will wait either 120 seconds, or for the timeLimit on the JS policy itself, whichever is lower.
As it has been implemented, the default wait time is the maximum wait time. Therefore the answer to the second question is the same.
Now we have to ask the similar question for this limit: what is the default and maximum-specifiable timeLimit on a JavaScript callout policy?
Ok, let's look at an example. Suppose I have this JS Policy:
<Javascript name='JS-ObtainExternalToken'> <IncludeURL>jsc://utility.js</IncludeURL> <ResourceURL>jsc://obtainExternalToken.js</ResourceURL> </Javascript>
If the JavaScript code in obtainExternalToken.js uses httpClient and calls waitForComplete(500), then the actual wait time will be 200ms.
Now, what happens when we modify the policy configuration to be like this, just adding an explicit timeLimit:
<Javascript name='JS-ObtainExternalToken' timeLimit='1200' > <IncludeURL>jsc://utility.js</IncludeURL> <ResourceURL>jsc://obtainExternalToken.js</ResourceURL> </Javascript>
Now, with the same JavaScript code in obtainExternalToken.js, the actual wait time will be 500ms on a commercial Edge SaaS org, or still 200ms on a trial Edge SaaS org.
@Floyd Jones - you might want to have a look see regarding the max and defaults for timeLimit and waitForDefault.