I have set timelimit 1 sec in JS policy
timeLimit="1000"
continueOnError="true" //also checked with false
When a JavaScript file takes too long to execute, I encounter a timeout error in Postman, and the subsequent policies do not execute. I've included a try-catch block in the API call within the JavaScript file, but it's not triggering as expected. I want to ensure that all policies run even if the JavaScript policy times out. I also tried using RaiseFault to handle this situation, but it isn’t working. Additionally, I need to set those errors in a variable so I can use them in subsequent policies based on certain conditions. I am working on Apigee Edge. FaultRules is also not working.
JS policy:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Javascript async="true" continueOnError="true" enabled="true" timeLimit="1000" name="JS-AuthHandler">
<DisplayName>JS-AuthHandler</DisplayName>
<Properties/>
<ResourceURL>jsc://AuthHandler.js</ResourceURL>
</Javascript>
Error:
That's not the right way to do it. You cannot define a FaultRule inside the policy.
I don't know why, sometimes the UI provides a template that includes FaultRules inside the policy. But in any case, it does not belong there.
You can insert FaultRules in the ProxyEndpoint or in the TargetEndpoint. Check the documentation on that. Your JS policy should be as simple as this:
<Javascript timeLimit="1000" name="JS-AuthHandler">
<ResourceURL>jsc://AuthHandler.js</ResourceURL>
</Javascript>
Thanks for the response.
We have to add retry logic for OAuth call written in the Js file then after target end point will call.
I have added FaultRule in ProxyEndpoint but it is not working. As i am getting timeout error from OAuth call not from target end point. How can i do this?
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |