replicate / replicate-go

Go client for Replicate
https://replicate.com
Apache License 2.0
65 stars 9 forks source link

fix: time.NewTicker method panics if argument is less than 0 #7

Closed lll-lll-lll-lll closed 1 year ago

lll-lll-lll-lll commented 1 year ago

What's Problem

The current implementation in the Client.Run method passes zero to the interval argument of the Wait method https://github.com/replicate/replicate-go/blob/d6f3d9a0308e6b1481784631932d4f7652e7ee36/run.go#L33

This cause panic when initializing time.NewTicker. https://github.com/replicate/replicate-go/blob/d6f3d9a0308e6b1481784631932d4f7652e7ee36/prediction.go#L103

Because time.NewTicker panics when its argument is a value less than or equal to zero.

func NewTicker(d Duration) *Ticker {
    if d <= 0 {
        panic(errors.New("non-positive interval for NewTicker"))
    }

tim.NewTicker()

What I did

mattt commented 1 year ago

@lll-lll-lll-lll Thanks again for your help. This change is now available in v0.4.1.

lll-lll-lll-lll commented 1 year ago

@mattt thank you for your review and update my PR