Skip to content

fix: add guard for disposed JCEF browser in sendToWebview#11897

Merged
RomneyDa merged 2 commits intomainfrom
browser-disposal
Mar 26, 2026
Merged

fix: add guard for disposed JCEF browser in sendToWebview#11897
RomneyDa merged 2 commits intomainfrom
browser-disposal

Conversation

@RomneyDa
Copy link
Collaborator

@RomneyDa RomneyDa commented Mar 26, 2026

Summary

  • Adds an isClosed guard before calling executeJavaScript in sendToWebview to prevent NPE when the JCEF browser is already disposed
  • Broadens the catch clause from IllegalStateException to Exception to handle NPE and other errors that propagate from deeper in JCEF

Fixes #8085, #9159

Test plan

  • Open a Continue sidebar panel in IntelliJ, close the project, and verify no NPE is logged
  • Verify normal webview messaging still works when the browser is active

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.

  • Bug Fixes
    • Return early if browser.cefBrowser.isClosed and log the message type before skipping executeJavaScript.
    • Catch Exception instead of IllegalStateException to handle NPEs and other JCEF errors.

Written for commit 01d876b. Summary will update on new commits.

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
@RomneyDa RomneyDa requested a review from a team as a code owner March 26, 2026 18:49
@RomneyDa RomneyDa requested review from sestinj and removed request for a team March 26, 2026 18:49
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Mar 26, 2026
@continue
Copy link
Contributor

continue bot commented Mar 26, 2026

Docs Review

No 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.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Log the message type before early-returning on a closed JCEF browser
to aid debugging silent message drops during project disposal.
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 26, 2026
@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Mar 26, 2026
@RomneyDa RomneyDa merged commit 204c9b6 into main Mar 26, 2026
66 checks passed
@RomneyDa RomneyDa deleted the browser-disposal branch March 26, 2026 21:29
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Mar 26, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[JetBrains] Sidebar panel frequently freezes across all OS'

2 participants