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

[FIXED] Change Fetch client timeout to a higher value #1689

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions js.go
Original file line number Diff line number Diff line change
Expand Up @@ -2899,10 +2899,11 @@ func (sub *Subscription) Fetch(batch int, opts ...PullOpt) ([]*Msg, error) {
}

// Make our request expiration a bit shorter than the current timeout.
expires := ttl
if ttl >= 20*time.Millisecond {
expires = ttl - 10*time.Millisecond
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
Expand Down Expand Up @@ -3166,10 +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 := ttl
if ttl >= 20*time.Millisecond {
expires = ttl - 10*time.Millisecond
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{
Expand Down
2 changes: 1 addition & 1 deletion test/js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ func TestPullSubscribeFetchBatchWithHeartbeat(t *testing.T) {
if msgs.Error() != nil {
t.Fatalf("Unexpected error: %s", msgs.Error())
}
if elapsed < 290*time.Millisecond {
if elapsed < 250*time.Millisecond {
t.Fatalf("Expected timeout after 300ms; got: %v", elapsed)
}

Expand Down