- Notifications
You must be signed in to change notification settings - Fork 7
Description
Now that Go 1.25 is out, and the security and support policy is that each major Go release is supported until there are two newer major releases, we can expect most people to be on Go 1.23 or newer.
The Go module of this package has not been updated to indicate that it supports Go 1.23 however, so I wonder whether this has been verified to work correctly with Go 1.23 and newer?
For instance, at least one of the inspirations for this library, jonboulle/clockwork does NOT work correctly with Go 1.23 or newer, see jonboulle/clockwork#98
Go 1.23 comes with behavior changes in timers, check out the full article: https://go.dev/wiki/Go123Timer
In short, three important changes:
- timers do not need to be closed if not used anymore
- you shouldn't bother about the state of timer before calling to
Resetanymore - channels must not be emptied after the
Stop()returnedfalse
The last part is very important, since existing calls to <-timer.Chan() now could lead to deadlocks, see godoc:
// For a chan-based timer created with NewTimer(d), as of Go 1.23, // any receive from t.C after Stop has returned is guaranteed to block // rather than receive a stale time value from before the Stop; In order to use Go 1.23+ with jonboulle/clockwork, you have to work around the issue by reproducing the pre-1.23 timers behavior and I wonder if this is also necessary with current Quartz:
func (f fakeClock) NewTimer(d time.Duration) internal.Timer { timer := f.clockworkFakeClock.NewTimer(d) if d == 0 { // Here we reproduce the pre-1.23 timers behavior since jonboulle/clockwork still have not fixed this yet, // see the issue: https://github.com/jonboulle/clockwork/issues/98 if !timer.Stop() { <-timer.Chan() } } return timer }