fix: add guard for disposed JCEF browser in sendToWebview#11897
Merged
fix: add guard for disposed JCEF browser in sendToWebview#11897
Conversation
Contributor
Docs ReviewNo documentation updates needed for this PR. Reason: This change is an internal bug fix for JCEF browser disposal handling in the JetBrains extension. It adds a defensive guard and broader exception handling to prevent NPEs on project close—purely implementation-level details that don't affect user-facing behavior, configuration, or usage patterns. |
Log the message type before early-returning on a closed JCEF browser to aid debugging silent message drops during project disposal.
Patrick-Erichsen
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isClosedguard before callingexecuteJavaScriptinsendToWebviewto prevent NPE when the JCEF browser is already disposedIllegalStateExceptiontoExceptionto handle NPE and other errors that propagate from deeper in JCEFFixes #8085, #9159
Test plan
Summary by cubic
Prevent NPEs when the JCEF browser is disposed by guarding
sendToWebview, broadening error handling, and logging a warning when messages are dropped. This avoids errors on project close and keeps webview messaging stable and debuggable.browser.cefBrowser.isClosedand log the message type before skippingexecuteJavaScript.Exceptioninstead ofIllegalStateExceptionto handle NPEs and other JCEF errors.Written for commit 01d876b. Summary will update on new commits.