File tree Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @grpc/grpc-js" ,
3
- "version" : " 1.9.2 " ,
3
+ "version" : " 1.9.3 " ,
4
4
"description" : " gRPC Library for Node - pure JS implementation" ,
5
5
"homepage" : " https://grpc.io/" ,
6
6
"repository" : " https://github.com/grpc/grpc-node/tree/master/packages/grpc-js" ,
Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ export class BackoffTimeout {
78
78
* running is true.
79
79
*/
80
80
private startTime : Date = new Date ( ) ;
81
+ /**
82
+ * The approximate time that the currently running timer will end. Only valid
83
+ * if running is true.
84
+ */
85
+ private endTime : Date = new Date ( ) ;
81
86
82
87
constructor ( private callback : ( ) => void , options ?: BackoffOptions ) {
83
88
if ( options ) {
@@ -100,6 +105,8 @@ export class BackoffTimeout {
100
105
}
101
106
102
107
private runTimer ( delay : number ) {
108
+ this . endTime = this . startTime ;
109
+ this . endTime . setMilliseconds ( this . endTime . getMilliseconds ( ) + this . nextDelay ) ;
103
110
clearTimeout ( this . timerId ) ;
104
111
this . timerId = setTimeout ( ( ) => {
105
112
this . callback ( ) ;
@@ -178,4 +185,12 @@ export class BackoffTimeout {
178
185
this . hasRef = false ;
179
186
this . timerId . unref ?.( ) ;
180
187
}
188
+
189
+ /**
190
+ * Get the approximate timestamp of when the timer will fire. Only valid if
191
+ * this.isRunning() is true.
192
+ */
193
+ getEndTime ( ) {
194
+ return this . endTime ;
195
+ }
181
196
}
Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ class DnsResolver implements Resolver {
175
175
} ) ;
176
176
this . backoff . stop ( ) ;
177
177
this . backoff . reset ( ) ;
178
+ this . stopNextResolutionTimer ( ) ;
178
179
return ;
179
180
}
180
181
if ( this . dnsHostname === null ) {
@@ -339,9 +340,9 @@ class DnsResolver implements Resolver {
339
340
private startResolutionWithBackoff ( ) {
340
341
if ( this . pendingLookupPromise === null ) {
341
342
this . continueResolving = false ;
342
- this . startResolution ( ) ;
343
343
this . backoff . runOnce ( ) ;
344
344
this . startNextResolutionTimer ( ) ;
345
+ this . startResolution ( ) ;
345
346
}
346
347
}
347
348
@@ -352,6 +353,11 @@ class DnsResolver implements Resolver {
352
353
* fires. Otherwise, start resolving immediately. */
353
354
if ( this . pendingLookupPromise === null ) {
354
355
if ( this . isNextResolutionTimerRunning || this . backoff . isRunning ( ) ) {
356
+ if ( this . isNextResolutionTimerRunning ) {
357
+ trace ( 'resolution update delayed by "min time between resolutions" rate limit' ) ;
358
+ } else {
359
+ trace ( 'resolution update delayed by backoff timer until ' + this . backoff . getEndTime ( ) . toISOString ( ) ) ;
360
+ }
355
361
this . continueResolving = true ;
356
362
} else {
357
363
this . startResolutionWithBackoff ( ) ;
Original file line number Diff line number Diff line change @@ -222,6 +222,7 @@ export class ResolvingLoadBalancer implements LoadBalancer {
222
222
* In that case, the backoff timer callback will call
223
223
* updateResolution */
224
224
if ( this . backoffTimeout . isRunning ( ) ) {
225
+ trace ( 'requestReresolution delayed by backoff timer until ' + this . backoffTimeout . getEndTime ( ) . toISOString ( ) ) ;
225
226
this . continueResolving = true ;
226
227
} else {
227
228
this . updateResolution ( ) ;
@@ -247,6 +248,8 @@ export class ResolvingLoadBalancer implements LoadBalancer {
247
248
configSelector : ConfigSelector | null ,
248
249
attributes : { [ key : string ] : unknown }
249
250
) => {
251
+ this . backoffTimeout . stop ( ) ;
252
+ this . backoffTimeout . reset ( ) ;
250
253
let workingServiceConfig : ServiceConfig | null = null ;
251
254
/* This first group of conditionals implements the algorithm described
252
255
* in https://github.com/grpc/proposal/blob/master/A21-service-config-error-handling.md
You can’t perform that action at this time.
0 commit comments