From 95ec711ff7ca4b237c509c25897ac76db2b2aab0 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 26 Mar 2026 11:49:37 -0700 Subject: [PATCH 1/2] fix: add guard for disposed JCEF browser in sendToWebview Before calling executeJavaScript, check if the browser is already closed to prevent NPE propagation from deeper in JCEF. Also broadens the catch from IllegalStateException to Exception to handle NPE and other errors that can occur when the browser is in a disposed state. Fixes #8085, #9159 --- .../continueintellijextension/browser/ContinueBrowser.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/browser/ContinueBrowser.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/browser/ContinueBrowser.kt index 914a87f0949..fd5057d8573 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/browser/ContinueBrowser.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/browser/ContinueBrowser.kt @@ -85,11 +85,12 @@ class ContinueBrowser( } fun sendToWebview(messageType: String, data: Any? = null, messageId: String = uuid()) { + if (browser.cefBrowser.isClosed) return val json = gsonService.gson.toJson(BrowserMessage(messageType, messageId, data)) val jsCode = """window.postMessage($json, "*");""" try { browser.cefBrowser.executeJavaScript(jsCode, getGuiUrl(), 0) - } catch (error: IllegalStateException) { + } catch (error: Exception) { log.warn(error) } } From 01d876b899a9a55cb951b7591c0124c9117a0683 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 26 Mar 2026 12:04:04 -0700 Subject: [PATCH 2/2] fix: add log warning when sending to disposed browser Log the message type before early-returning on a closed JCEF browser to aid debugging silent message drops during project disposal. --- .../continueintellijextension/browser/ContinueBrowser.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/browser/ContinueBrowser.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/browser/ContinueBrowser.kt index fd5057d8573..e4380d31115 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/browser/ContinueBrowser.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/browser/ContinueBrowser.kt @@ -85,7 +85,10 @@ class ContinueBrowser( } fun sendToWebview(messageType: String, data: Any? = null, messageId: String = uuid()) { - if (browser.cefBrowser.isClosed) return + if (browser.cefBrowser.isClosed) { + log.warn("Attempted to send message to disposed browser: $messageType") + return + } val json = gsonService.gson.toJson(BrowserMessage(messageType, messageId, data)) val jsCode = """window.postMessage($json, "*");""" try {