File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
packages/grpc-js-xds/interop Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,13 @@ class CallStatsTracker {
130
130
131
131
private subscribers : CallSubscriber [ ] = [ ] ;
132
132
133
+ private removeSubscriber ( subscriber : CallSubscriber ) {
134
+ const index = this . subscribers . indexOf ( subscriber ) ;
135
+ if ( index >= 0 ) {
136
+ this . subscribers . splice ( index , 1 ) ;
137
+ }
138
+ }
139
+
133
140
getCallStats ( callCount : number , timeoutSec : number ) : Promise < LoadBalancerStatsResponse > {
134
141
return new Promise ( ( resolve , reject ) => {
135
142
let finished = false ;
@@ -142,7 +149,7 @@ class CallStatsTracker {
142
149
setTimeout ( ( ) => {
143
150
if ( ! finished ) {
144
151
finished = true ;
145
- this . subscribers . splice ( this . subscribers . indexOf ( subscriber ) , 1 ) ;
152
+ this . removeSubscriber ( subscriber ) ;
146
153
resolve ( subscriber . getFinalStats ( ) ) ;
147
154
}
148
155
} , timeoutSec * 1000 )
@@ -155,7 +162,7 @@ class CallStatsTracker {
155
162
for ( const subscriber of callSubscribers ) {
156
163
subscriber . addCallStarted ( ) ;
157
164
if ( ! subscriber . needsMoreCalls ( ) ) {
158
- this . subscribers . splice ( this . subscribers . indexOf ( subscriber ) , 1 ) ;
165
+ this . removeSubscriber ( subscriber ) ;
159
166
}
160
167
}
161
168
return {
You can’t perform that action at this time.
0 commit comments