Skip to content

Commit afb6b21

Browse files
authored
fix: prevent responseListeners memory leak in CoreMessenger (continuedev#11901)
Response listeners were only removed when data contained `"done": true`, but most message types (file events, autocomplete, nextEdit, etc.) return responses without a `done` field. This caused every fire-and-forget request to leak its callback lambda permanently in the map. Over a long session with heavy autocomplete and file navigation, this could accumulate hundreds of thousands of entries (40-100+ MB). Fix: invert the removal logic — remove the listener by default, and only keep it when `done == false` (i.e., a streaming response is still in progress). This preserves existing streaming behavior while ensuring all non-streaming responses are cleaned up immediately.
1 parent 581980e commit afb6b21

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue

extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ class CoreMessenger(
6565
responseListeners[messageId]?.let { listener ->
6666
listener(data)
6767
@Suppress("UNCHECKED_CAST")
68-
val done = (data as? Map<String, Boolean>)?.get("done")
68+
val done = (data as? Map<String, Any>)?.get("done") as? Boolean
6969

70-
if (done == true) {
70+
// Remove unless explicitly streaming (done == false)
71+
if (done != false) {
7172
responseListeners.remove(messageId)
7273
}
7374
}

0 commit comments

Comments
 (0)