Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Commit 05548d5

Browse files
authored
fix: editing retry logic (#1100)
1 parent 5bdb180 commit 05548d5

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/gax.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,32 @@ export class CallSettings {
211211
let longrunning = this.longrunning;
212212
let apiName = this.apiName;
213213
let retryRequestOptions = this.retryRequestOptions;
214+
// If a method-specific timeout is set in the service config, and the retry codes for that
215+
// method are non-null, then that timeout value will be used to
216+
// override backoff settings.
217+
if (
218+
retry !== undefined &&
219+
retry !== null &&
220+
retry.retryCodes !== null &&
221+
retry.retryCodes.length > 0
222+
) {
223+
retry.backoffSettings.initialRpcTimeoutMillis = timeout;
224+
retry.backoffSettings.maxRpcTimeoutMillis = timeout;
225+
retry.backoffSettings.totalTimeoutMillis = timeout;
226+
}
227+
// If the user provides a timeout to the method, that timeout value will be used
228+
// to override the backoff settings.
214229
if ('timeout' in options) {
215230
timeout = options.timeout!;
231+
if (
232+
retry !== undefined &&
233+
retry !== null &&
234+
retry.retryCodes.length > 0
235+
) {
236+
retry.backoffSettings.initialRpcTimeoutMillis = timeout;
237+
retry.backoffSettings.maxRpcTimeoutMillis = timeout;
238+
retry.backoffSettings.totalTimeoutMillis = timeout;
239+
}
216240
}
217241
if ('retry' in options) {
218242
retry = mergeRetryOptions(retry || ({} as RetryOptions), options.retry!);

0 commit comments

Comments
 (0)