Hi Apigee Community!
Is there a way to setup a time limit of 50s to the httpClient.send and then when it reach the time limit, the process will exit the js policy and continue without error? (the goal of this is to exit the JS policy before the message processor timeout)
setTimeout and setInterval method are not supported by the JS in Apigee Edge, and waitforComplete is not good to use. Any suggestion on how to do that?
I believe you can use the timeLimit attribute for this purpose. There is no documentation on what the valid range is, for the timeLimit. I suppose it must be positive, but I'm unsure if there is an upper limit. If you want 50 seconds you can try timeLimit="50000"
, along with continueOnError="true"
.
<Javascript name='JS-1' continueOnError="true" timeLimit='50000' >
<ResourceURL>jsc://my-script-here.js</ResourceURL>
</Javascript>
If you don't set continueOnError="true", then when the JS step exceeds the time limit, the system will enter fault flow. It sounds like you don't want that; you want the processing to continue with "as much information as the JS step has provided." Do do that, use the continueOnError="true".
I tried by adding the continueOnError="true" in JS policy when getting time limit exceeds but still next preflow step not being executed as you can see in above image that after last JS ste, no other step got run.
Hi @chetannarula27, Can you confirm that the error is in fact a time limit exceeds error?
@friasc Would like to provide more update is, Inside AuthHandler.JS file, we are calling rest api end point to get token. I tried the continueOnError using some loop which took more then time limit to execute and got the time limit error but also execute the next flow steps.
Seems, like if calling rest api and use callback and in case, time limit error happened then execution got stop and returned the error from that policy
Hi @friasc do we know why continueOnError not working in JS policy when calling http end point in JS file.
Hi @chetannarula27! I would like to take note that setting the attribute continueOnError is just one step in making sure that faults and exceptions are properly managed. Fault handling beyond what is available on the policy as an attribute is covered with fault handling rules and error flows that are available. It may be necessary to make use of the Fault rules so that you can manage faults as you deem it necessary. Also, perhaps you have a better answer but let's bear in mind that the JavaScript being executed can in fact exceed time limits if not constrained by reading time limit variables set in the proxy. If the JavaScript execution does in fact exceed time limits then it may be necessary to ensure that the JavaScript invocation is exiting gracefully or you may need to manage the exception by making use of fault rules.