Skip to content

Commit fdb6064

Browse files
authored
fix: xds-client LrsCallState statsTimer memory leak
1 parent 34b82cb commit fdb6064

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,13 @@ class LrsCallState {
688688
this.sendStats();
689689
}
690690

691+
destroy() {
692+
if (this.statsTimer) {
693+
this.statsTimer = clearInterval(this.statsTimer);
694+
}
695+
return null;
696+
}
697+
691698
private handleStreamStatus(status: StatusObject) {
692699
this.client.trace(
693700
'LRS stream ended. code=' + status.code + ' details= ' + status.details
@@ -938,7 +945,7 @@ class XdsSingleServerClient {
938945
}
939946

940947
handleLrsStreamEnd() {
941-
this.lrsCallState = null;
948+
this.lrsCallState = this.lrsCallState ? this.lrsCallState.destroy() : null;
942949
/* The backoff timer would start the stream when it finishes. If it is not
943950
* running, restart the stream immediately. */
944951
if (!this.lrsBackoff.isRunning()) {

0 commit comments

Comments
 (0)