Skip to content

Commit d2a6dda

Browse files
authored
Merge pull request #2891 from gfrancz/xds-lrscallstate-memory-leak
fix: xds-client LrsCallState statsTimer memory leak
2 parents d2462ca + 6dc3abe commit d2a6dda

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/grpc-js-xds/src/xds-client.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,14 @@ class LrsCallState {
688688
this.sendStats();
689689
}
690690

691+
destroy() {
692+
if (this.statsTimer) {
693+
clearInterval(this.statsTimer);
694+
this.statsTimer = null;
695+
}
696+
return null;
697+
}
698+
691699
private handleStreamStatus(status: StatusObject) {
692700
this.client.trace(
693701
'LRS stream ended. code=' + status.code + ' details= ' + status.details
@@ -938,7 +946,7 @@ class XdsSingleServerClient {
938946
}
939947

940948
handleLrsStreamEnd() {
941-
this.lrsCallState = null;
949+
this.lrsCallState = this.lrsCallState ? this.lrsCallState.destroy() : null;
942950
/* The backoff timer would start the stream when it finishes. If it is not
943951
* running, restart the stream immediately. */
944952
if (!this.lrsBackoff.isRunning()) {

0 commit comments

Comments
 (0)