-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Description
I have the following javascript code to pause the workflow until certain time. The code seems to work as expected, as the "alert()" function pops up at the desired time. But after the alert, the workflow is still in waiting. In the log, the work flow keeps running. I have to manually terminate it. The block after the javascript never runs.
async function delayUntilTime(targetHour, targetMinute) {
const now = new Date();
const targetTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), targetHour, targetMinute, 0, 0);
// If the target time has already passed today, set it for tomorrow
if (now > targetTime) {
targetTime.setDate(targetTime.getDate() + 1);
}
const delayDuration = targetTime.getTime() - now.getTime();
console.log(`Waiting for ${delayDuration / 1000} seconds until ${targetTime.toLocaleTimeString()}`);
console.log(delayDuration);
await new Promise(resolve => setTimeout(resolve, delayDuration));
alert('timeout!');
automaNextBlock();
}
// Call the function with your desired time (e.g., 8 AM)
delayUntilTime(0, 8);
Metadata
Metadata
Assignees
Labels
No labels