Skip to content

retry: keep the caller's request timeout - #152

Merged
boks1971 merged 1 commit into
mainfrom
raja/retry-keep-caller-timeout
Oct 6, 2026
Merged

boks1971 merged 1 commit into
mainfrom
raja/retry-keep-caller-timeout

Conversation

@boks1971

@boks1971 boks1971 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Human note: Ordering the timeout per caller's deadline makes sense, but quite a far reaching one. Should we do this?

The retry interceptor no longer replaces a timeout the caller set.

The interceptor added its own attempt timeout after the caller's options (retry.go#L42-L47). Options apply in order, so the attempt timeout always won. A caller that asked for 25 s got 3 s, 5 s, then 7 s. A caller that passed its context deadline got 3 s, and a call that was still running could then be sent again.

Production shows both. In 7 days, none of 37 million DeleteRoom calls took longer than 5 s, although the caller asks for 25 s. AssignJob has a 10 s budget on the worker but times out at 3 s about 3,300 times a day, and each timeout is retried. Although there are no logs, I think a retry that arrives while the first assignment is still running can potentially start a second one?

Now the attempt timeout goes first, and a caller's timeout overrides it. Callers that set no timeout keep the same behavior. Streams get the same fix.

This reaches every client that uses the retry interceptor and passes a timeout. A caller that passes its whole context deadline now gets one attempt with that deadline. A fast failure, such as Unavailable, still retries.

TestCallerTimeoutKept sets a 1 s timeout. On main the attempts get 100, 300 and 500 ms.

🤖 Generated with Claude Code

The retry interceptor added its attempt timeout after the caller's
options, so it always replaced a timeout the caller set. Put it first,
so the caller's timeout wins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@boks1971
boks1971 merged commit ac5681d into main Oct 6, 2026
8 checks passed
@boks1971
boks1971 deleted the raja/retry-keep-caller-timeout branch October 6, 2026 05:32
boks1971 added a commit that referenced this pull request Oct 7, 2026
)

#152 put the attempt timeout before the caller's options so a caller's
timeout wins. A retry interceptor nested inside another one then took the
outer one's timeout for a caller's, and the outer timeout won. The
outermost retry interceptor now passes the caller's own timeout down in
the context. Without one, the innermost interceptor's timeout wins.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants