Skip to content

Commit b3063e4

Browse files
Limit gRPC's built-in exponential backoff (#1390)
* Prevent gRPC from performing too much exponential backoff * [AUTOMATED]: Prettier Code Styling * Simplify comment * Set the initial backoff as low as possible * revert testing change
1 parent 06ee761 commit b3063e4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/firestore/src/platform_node/grpc_connection.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,17 @@ export class GrpcConnection implements Connection {
113113
? grpc.credentials.createSsl()
114114
: grpc.credentials.createInsecure();
115115
this.cachedStub = {
116-
stub: new this.firestore.Firestore(this.databaseInfo.host, credentials),
116+
stub: new this.firestore.Firestore(
117+
this.databaseInfo.host,
118+
credentials,
119+
{
120+
// We do our own connection backoff (that for example is aware of whether or
121+
// not a write stream error is permanent or not) so we don't want gRPC to do
122+
// backoff on top of that. 100ms is the minimum value that gRPC allows.
123+
'grpc.initial_reconnect_backoff_ms': 100,
124+
'grpc.max_reconnect_backoff_ms': 100
125+
}
126+
),
117127
token
118128
};
119129
}

0 commit comments

Comments
 (0)