You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every 1 minutes: 2024-03-15T03:31:38.002Z
Every 1 minutes: 2024-03-15T03:31:39.003Z
Every 1 minutes: 2024-03-15T03:31:40.016Z
Every 1 minutes: 2024-03-15T03:31:41.009Z
Every 1 minutes: 2024-03-15T03:31:42.012Z
But when i stop and call again. The result is
Every 1 minutes: 2024-03-15T03:31:50.016Z
Every 1 minutes: 2024-03-15T03:31:51.008Z
Every 1 minutes: 2024-03-15T03:31:51.009Z
Every 1 minutes: 2024-03-15T03:31:52.015Z
Every 1 minutes: 2024-03-15T03:31:52.015Z
It's seem have another job run in the same time. How can i fix it ?
The text was updated successfully, but these errors were encountered:
Your code behaves as expected because you're not resetting the job and simply adding a new callback, the previous callbacks are still present and will all be called upon job execution.
This means there is only one job running but with multiple callbacks. If you'd like to reset it, you would have to recreate it altogether, and probably make sure it was stopped before doing so (to avoid having multiple jobs running at once):
exportasyncfunctionPOST(request){constrequestData=awaitrequest.json();const{ trigger, value, groupFlows, checkPublished, wId, lNodes, lEdges }=requestData.body;if(checkPublished){// make sure the previous job is stopped before overriding itjob.stop();// re-create a new job in place of the previous onejob=CronJob.from({cronTime: "* * * * * *",onTick: ()=>{constd=newDate();console.log(`Every ${value}${trigger}:`,d);},timeZone: "UTC+7",start: true});returnNextResponse.json({success: true,});}else{job.stop();returnNextResponse.json({success: true,});}}
Linking to our previous discussion for later reference: #864
This is my code
When i call in the first time. The result is
But when i stop and call again. The result is
It's seem have another job run in the same time. How can i fix it ?
The text was updated successfully, but these errors were encountered: