Skip to content

Commit b38c70c

Browse files
Bring gRPC retry options in line with other SDKs. (#1368)
## What was changed * Raise initial interval to 100ms (from 20ms) * Drop max interval to 5s (from 10s) * Drop backoff factor to 1.7 (from 2.0) * Raise jitter factor to 0.2 (from 0.1) ## Why? The current retry options for the TypeScript SDK are a little wonky, as the existing initial interval is *by far* the most aggressive among all Temporal SDKs. This brings the default parameters in line with the changes already made to the Java SDK and in flight for the Core SDK. This also fixes a wart: the TypeScript SDK can exhaust all retries in 9.200 seconds, if the random jitters for each retry align in just the right way, and we want all SDKs to keep retrying for at least 10 seconds after the initial failure. This advances progress on temporalio/features#27 (aka SDK-118 in internal Jira).
1 parent fd6a0c7 commit b38c70c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/client/src/grpc-retry.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface BackoffOptions {
2626
/**
2727
* Exponential backoff factor
2828
*
29-
* @default 2
29+
* @default 1.7
3030
*/
3131
factor: number;
3232

@@ -39,20 +39,20 @@ export interface BackoffOptions {
3939
/**
4040
* Maximum amount of jitter to apply
4141
*
42-
* @default 0.1
42+
* @default 0.2
4343
*/
4444
maxJitter: number;
4545
/**
4646
* Function that returns the "initial" backoff interval based on the returned status.
4747
*
48-
* The default is 1 second for RESOURCE_EXHAUSTED errors and 20 millis for other retryable errors.
48+
* The default is 1 second for RESOURCE_EXHAUSTED errors and 100 millis for other retryable errors.
4949
*/
5050
initialIntervalMs(status: StatusObject): number;
5151

5252
/**
5353
* Function that returns the "maximum" backoff interval based on the returned status.
5454
*
55-
* The default is 10 seconds regardless of the status.
55+
* The default is 5 seconds regardless of the status.
5656
*/
5757
maxIntervalMs(status: StatusObject): number;
5858
}
@@ -68,11 +68,11 @@ function withDefaultBackoffOptions({
6868
}: Partial<BackoffOptions>): BackoffOptions {
6969
return {
7070
maxAttempts: maxAttempts ?? 10,
71-
factor: factor ?? 2,
72-
maxJitter: maxJitter ?? 0.1,
71+
factor: factor ?? 1.7,
72+
maxJitter: maxJitter ?? 0.2,
7373
initialIntervalMs: initialIntervalMs ?? defaultInitialIntervalMs,
7474
maxIntervalMs() {
75-
return 10_000;
75+
return 5_000;
7676
},
7777
};
7878
}
@@ -125,7 +125,7 @@ function defaultInitialIntervalMs({ code }: StatusObject) {
125125
if (code === grpc.status.RESOURCE_EXHAUSTED) {
126126
return 1000;
127127
}
128-
return 20;
128+
return 100;
129129
}
130130

131131
/**

0 commit comments

Comments
 (0)