diff --git a/js.go b/js.go index 5bea1b976..9fec788a7 100644 --- a/js.go +++ b/js.go @@ -2899,7 +2899,11 @@ func (sub *Subscription) Fetch(batch int, opts ...PullOpt) ([]*Msg, error) { } // Make our request expiration a bit shorter than the current timeout. - expires := time.Duration(float64(ttl) * 0.9) + expiresDiff := time.Duration(float64(ttl) * 0.1) + if expiresDiff > 5*time.Second { + expiresDiff = 5 * time.Second + } + expires := ttl - expiresDiff nr.Batch = batch - len(msgs) nr.Expires = expires @@ -3163,7 +3167,11 @@ func (sub *Subscription) FetchBatch(batch int, opts ...PullOpt) (MessageBatch, e ttl = time.Until(deadline) // Make our request expiration a bit shorter than the current timeout. - expires := time.Duration(float64(ttl) * 0.9) + expiresDiff := time.Duration(float64(ttl) * 0.1) + if expiresDiff > 5*time.Second { + expiresDiff = 5 * time.Second + } + expires := ttl - expiresDiff requestBatch := batch - len(result.msgs) req := nextRequest{