Skip to content

Commit 656ca0c

Browse files
authored
Merge pull request #2898 from murgatroid99/grpc-js-xds_memory_leak_backport_1.12.x
grpc-js-xds: fix LrsCallState statsTimer memory leak
2 parents 6bd791d + f1f2b2d commit 656ca0c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/grpc-js-xds/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@grpc/grpc-js-xds",
3-
"version": "1.12.1",
3+
"version": "1.12.2",
44
"description": "Plugin for @grpc/grpc-js. Adds the xds:// URL scheme and associated features.",
55
"main": "build/src/index.js",
66
"scripts": {

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,14 @@ class LrsCallState {
682682
this.sendStats();
683683
}
684684

685+
destroy() {
686+
if (this.statsTimer) {
687+
clearInterval(this.statsTimer);
688+
this.statsTimer = null;
689+
}
690+
return null;
691+
}
692+
685693
private handleStreamStatus(status: StatusObject) {
686694
this.client.trace(
687695
'LRS stream ended. code=' + status.code + ' details= ' + status.details
@@ -932,7 +940,7 @@ class XdsSingleServerClient {
932940
}
933941

934942
handleLrsStreamEnd() {
935-
this.lrsCallState = null;
943+
this.lrsCallState = this.lrsCallState ? this.lrsCallState.destroy() : null;
936944
/* The backoff timer would start the stream when it finishes. If it is not
937945
* running, restart the stream immediately. */
938946
if (!this.lrsBackoff.isRunning()) {

0 commit comments

Comments
 (0)