File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed 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 @@ -353,6 +353,11 @@ class DnsResolver implements Resolver {
353
353
* fires. Otherwise, start resolving immediately. */
354
354
if ( this . pendingLookupPromise === null ) {
355
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
+ }
356
361
this . continueResolving = true ;
357
362
} else {
358
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 ( ) ;
You can’t perform that action at this time.
0 commit comments