stop double execution of code when the time limit exceedes

var worker_default = {
  async fetch(request, env, ctx) {
    let counter = 0
    while(true){
      console.log(counter)
      counter+=1
      await new Promise((resolve) => setTimeout(resolve, 1000));
    }
    return new Response("Hello World!");
  }
};


Its printing 0,1,2,3...59 then again the loop is running and printing 0,1,2,3....59 then it stops
Was this page helpful?