Closed m-s-sh closed 10 months ago
When I add a new job (let's say j) and after that calling j.NextRun(), it fails unpredictable with ErrJobNotFound.
Steps to reproduce the behavior:
func TestNextRun(t *testing.T) { clock := clockwork.NewFakeClock() sch, err := gocron.NewScheduler(gocron.WithClock(clock)) require.NoError(t, err) for i := 0; i < 10; i++ { var c int j, err := sch.NewJob( gocron.DurationJob(time.Second), gocron.NewTask(func() error { c++ t.Log("c", c) return nil }), gocron.WithName("calcJob"), gocron.WithSingletonMode(gocron.LimitModeReschedule), ) require.NoError(t, err) sch.Start() r, err := j.NextRun() require.NoError(t, err, "i=%d", i) t.Log("nextRun", r) } }
v2.1.2
I expect not to fail with ErrJobNotFound, when I added job few lines above.
@mihailstefanov thanks for reporting this! An issue with not properly waiting for the new job to be instantiated before returning. I'll have a fix up soon.
Describe the bug
When I add a new job (let's say j) and after that calling j.NextRun(), it fails unpredictable with ErrJobNotFound.
To Reproduce
Steps to reproduce the behavior:
Version
v2.1.2
Expected behavior
I expect not to fail with ErrJobNotFound, when I added job few lines above.