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
later.date.localTime();consttimeStr=moment().add(1,'m').format('HH:mm');// time of next minuteconsttext=`at ${timeStr} also every 1 hour`;// want to trigger `fn` at next minute and every hour from now on.console.log(`text: ${text}`)constsched=later.parse.text(text);console.log(`next 10 occurence: `,later.schedule(sched).next(24));// this display right.constfn=function(){console.log(`curr time: `,moment().format('HH:mm:ss'));console.log(`next 10 occurence: `,later.schedule(sched).next(24));};later.setInterval(fn,sched);// the `fn` function will be triggered 100+ times after one minute from now on.
As commented above.
I want to trigger at next minute AND every 1 hour from now on.
later.schedule.next() function works well. It displays exactly what I expect.
But, when invoke setInterval(), fn will be invoked 100+ times at the next minute in a flash.
This issue and entire repo is a little cold, but in case anyone stumbles upon here with a similar issue, here's my two cents.
I had a similar issue, but I was using simple schedules, instead of any of the schedule-building methods. I eventually discovered it was an issue where I had a schedule that included [ {m:[30]}, {h:[0,9]} ]. I wanted it to fire at the bottom of every hour, and also at the top of hours 0 and 9 - and I thought that was how to do it. As @zjh1943 mentioned above, the later.schedule.next() seemed to indicate that everything would go according to my plan. However, the setInterval() went haywire at 0030 and 0930, calling over and over again. To fix, I changed it to [ {m:[30]}, {h:[0,9], m:[0]} ] so that the 2nd schedule was explicit with its' minutes. It's not clear from the documentation if this is how it is supposed to work.
Code Explain
Code like the below:
As commented above.
later.schedule.next()
function works well. It displays exactly what I expect.setInterval()
,fn
will be invoked 100+ times at the next minute in a flash.How to Replay
You can replay the bug on https://jsfiddle.net/xLobgnuh/6/:
Log
When you run the code above, console log will be like this:
LOG - CLICK TO SHOW
The text was updated successfully, but these errors were encountered: