Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - "call of reflect.Value.Type on zero Value" error when using in SingletonMode #376

Closed
Jonas096 opened this issue Aug 22, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Jonas096
Copy link

Describe the bug

When using the SingletonMode the module panics with the error "call of reflect.Value.Type on zero Value". The weird thing is, this error applys only 3 of 4 times. Sometimes the applications starts well.

To Reproduce

My Setup is like this

`func InitScheduler() {
gocron.SetPanicHandler(func(jobName string, recoverData interface{}) {
logs.Logger.Panicln("jobName", jobName, "error", recoverData)
})
Scheduler = gocron.NewScheduler(time.UTC)

//maximal werden 5 Jobs gleichzeitig durchgeführt
//jeder Job danach wird einfach in eine Warteschlange gesetzt
Scheduler.SetMaxConcurrentJobs(5, gocron.WaitMode)

//wenn der Job noch läuft, und eigentlich jetzt wieder an der Zeit durchgeführt werden sollte
//wird er nicht wieder ausgeführt
Scheduler.SingletonMode()

defer Scheduler.StartAsync()

}`

Version

go 1.18
github.com/go-co-op/gocron v1.16.2

Expected behavior

No Panic at start of the application

@Jonas096 Jonas096 added the bug Something isn't working label Aug 22, 2022
@jerebtw
Copy link

jerebtw commented Oct 20, 2022

I also have this bug

@JohnRoesler
Copy link
Contributor

@jerebtw @Jonas096 sorry for the late reply!

Scheduler.SingletonMode() is meant to be called in a chain defining a job. For example:

Scheduler.Every(10).Second().SingletonMode().Do(func() {
	log.Println("hello")
})

The global scheduler option is:

Scheduler = gocron.NewScheduler(time.UTC)
Scheduler.SetMaxConcurrentJobs(5, gocron.WaitMode)
Scheduler.SingletonModeAll()

This isn't handled well currently as you've encountered. I'll push up a fix to catch this situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants