Does Javascript Policy continue the processing when timeout is reached and continueOnError=true?

Hi,

We are using JavaScript policy to generate the log message with timeout as 250ms and continueOnError=true.

In MP's system.log, we see the below log:

policy:createLogMessage Apigee-Main-11 INFO JAVASCRIPT.EXEC - JSContect.hasExpired() : JSStep Timeout. Time Limit was 250ms. Execution expired by 401ms. Time Spent in Major GC 0ms. Time Spent in All GC 0ms. Num of GC events 0. JS Ran for 651ms, InstructionCount=2058

1. From the log, it looks like JavaScript Policy continued processing in the background and completed in 651ms. Is that correct?

2. Next to JS is the Message Logging Policy in the PostProxy FlowHook. In the above-mentioned scenario (If JavaScript keeps executing in the background), will next policy(Message Logging) be executed again once JS finishes the execution?

0 2 326
2 REPLIES 2

1. From the log, it looks like JavaScript Policy continued processing in the background and completed in 651ms. Is that correct?

Yes, your interpretation is correct.

2. Next to JS is the Message Logging Policy in the PostProxy FlowHook. In the above-mentioned scenario (If JavaScript keeps executing in the background), will next policy(Message Logging) be executed again once JS finishes the execution?

Are you saying that JS runs in the postproxy flow hook also?

To answer your question: in general, YES, the policy that follows a JS policy that has timedout, will run after the JS policy has completed, either naturally or via timeout.

I don't understand what you are implying by asking "will the next policy(Message Logging) be executed again ..."

What do you mean by "again"? The policy should execute once. Not twice, not "again".

Hi @Dino-at-Google,

Let me re-explain point 2:

I have 2 policies in PostProxy Flowhook - JavaScript to generate the log message and next Message Logging to log the generated message to file.

In normal flow (when javascript execution completed under 250ms), it generates the log message. Message Logging policy executes next, logs the message to file. All is good.

When javascript execution does not complete in 250ms, as per my assumption, next policy(Message Logging) will execute after timeLimit(250ms) since continueOnError=true for JS and will log null for logMessage variable.

<Message>{organization.name}-{environment.name}-{logMessage}</Message>

MP system.log shows Javascript continued to execute in the background and completed in 651ms. So I was just thinking if there is any way Message Logging can again execute after JS has finished execution?