cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Workflow using process.exit

henk_stobbe
DynaMight Leader
DynaMight Leader
Good morning,
 
My (workflow) script fetches data in a loop, and when a certain condition is met, the script needs to stop completely. I want to use process.exit for this. Is this a problem?
 
As an more clear example see below:
let x = 1;
 
while (x > 0) {
    console.log(x);
    x++;
 
    if (x > 10) {
        console.log('Exiting...');
        process.exit();
    }
}
 
Any problems in this?
KR Henk
2 REPLIES 2

christian_kreuz
Dynatrace Advisor
Dynatrace Advisor

As far as I know, process.exit() is not supported by our runtime.

I would recommend doing this via Run JavaScript and "return":

 

export default async function ({ executionId }) {
  let x = 1;
 
  while (x > 0) {
    console.log(x);
    x++;
   
    if (x > 10) {
      console.log('Exiting...');
      return;  
    }
  }}

 

 

christian_kreuz_0-1739196133012.png

 

henk_stobbe
DynaMight Leader
DynaMight Leader

Hi Christian,

Clear, so if you are in a subroutine  you can only do a return out of that routine to prevent spaghetti (-;

KR Henk

 

Featured Posts