Use of setInterval/ setTimeOut's in my js



I’m trying to use setInterval in my javascript to check for a certain condition to be true in a certain interval and clear the Interval checking after my condition is met. Below is my function usage -
function myExposedFunction() {
// some functionality
refreshIntervalId = setInterval(myFunction1, 10000);

  function myFunction1() {"12345");
    if (myCondition) {
      //some functionality

my .c3typ files will have the above function exposed as

type myC3Type{
myExposedFunction: function(): any js server

When the above is deployed and tried to test with - myC3Type.myExposedFunction() in my console I’m seeing an error -
"error: C3.typesys.Obj
cause: C3.typesys.Obj {template: “ReferenceError: “setInterval” is not defined. (AutoDeploy_cronJobDeploy.js#164)”,
key: “”
parameters: Array(3)
0: “wrapped org.mozilla.javascript.EcmaError: ReferenceError: “setInterval” is not defined. (AutoDeploy_cronJobDeploy.js#164)”
1: “null”
2: “org.mozilla.javascript.EcmaError: ReferenceError: “setInterval” is not defined. (AutoDeploy_cronJobDeploy.js#164)”


For server-side JavaScript execution (js server), neither setInterval nor setTimeout are available. Scripts are run synchronously, and execution returns to the caller as soon as the function that was called returns, which doesn’t allow for asynchronous side effects.