mirror of https://github.com/grpc/grpc-node.git
grpc-js: Remove watcher from queue before calling watcher callback. Fixes #1352
In the case where a new watcher is synchronously added to the watcher queue via the watcher callback, this can result in the callback being called multiple times. To support this case, the watcher needs to be move removed from the queue before calling the watcher callback.
This commit is contained in:
parent
7eca188ae1
commit
4e7b94ab35
|
@ -381,9 +381,9 @@ export class ChannelImplementation implements Channel {
|
|||
const watchersCopy = this.connectivityStateWatchers.slice();
|
||||
for (const watcherObject of watchersCopy) {
|
||||
if (newState !== watcherObject.currentState) {
|
||||
watcherObject.callback();
|
||||
clearTimeout(watcherObject.timer);
|
||||
this.removeConnectivityStateWatcher(watcherObject);
|
||||
watcherObject.callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue