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 11{
22 "name" : " @grpc/grpc-js" ,
3- "version" : " 1.9.2 " ,
3+ "version" : " 1.9.3 " ,
44 "description" : " gRPC Library for Node - pure JS implementation" ,
55 "homepage" : " https://grpc.io/" ,
66 "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 {
7878 * running is true.
7979 */
8080 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 ( ) ;
8186
8287 constructor ( private callback : ( ) => void , options ?: BackoffOptions ) {
8388 if ( options ) {
@@ -100,6 +105,8 @@ export class BackoffTimeout {
100105 }
101106
102107 private runTimer ( delay : number ) {
108+ this . endTime = this . startTime ;
109+ this . endTime . setMilliseconds ( this . endTime . getMilliseconds ( ) + this . nextDelay ) ;
103110 clearTimeout ( this . timerId ) ;
104111 this . timerId = setTimeout ( ( ) => {
105112 this . callback ( ) ;
@@ -178,4 +185,12 @@ export class BackoffTimeout {
178185 this . hasRef = false ;
179186 this . timerId . unref ?.( ) ;
180187 }
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+ }
181196}
Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ class DnsResolver implements Resolver {
175175 } ) ;
176176 this . backoff . stop ( ) ;
177177 this . backoff . reset ( ) ;
178+ this . stopNextResolutionTimer ( ) ;
178179 return ;
179180 }
180181 if ( this . dnsHostname === null ) {
@@ -339,9 +340,9 @@ class DnsResolver implements Resolver {
339340 private startResolutionWithBackoff ( ) {
340341 if ( this . pendingLookupPromise === null ) {
341342 this . continueResolving = false ;
342- this . startResolution ( ) ;
343343 this . backoff . runOnce ( ) ;
344344 this . startNextResolutionTimer ( ) ;
345+ this . startResolution ( ) ;
345346 }
346347 }
347348
@@ -352,6 +353,11 @@ class DnsResolver implements Resolver {
352353 * fires. Otherwise, start resolving immediately. */
353354 if ( this . pendingLookupPromise === null ) {
354355 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+ }
355361 this . continueResolving = true ;
356362 } else {
357363 this . startResolutionWithBackoff ( ) ;
Original file line number Diff line number Diff line change @@ -222,6 +222,7 @@ export class ResolvingLoadBalancer implements LoadBalancer {
222222 * In that case, the backoff timer callback will call
223223 * updateResolution */
224224 if ( this . backoffTimeout . isRunning ( ) ) {
225+ trace ( 'requestReresolution delayed by backoff timer until ' + this . backoffTimeout . getEndTime ( ) . toISOString ( ) ) ;
225226 this . continueResolving = true ;
226227 } else {
227228 this . updateResolution ( ) ;
@@ -247,6 +248,8 @@ export class ResolvingLoadBalancer implements LoadBalancer {
247248 configSelector : ConfigSelector | null ,
248249 attributes : { [ key : string ] : unknown }
249250 ) => {
251+ this . backoffTimeout . stop ( ) ;
252+ this . backoffTimeout . reset ( ) ;
250253 let workingServiceConfig : ServiceConfig | null = null ;
251254 /* This first group of conditionals implements the algorithm described
252255 * 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