Skip to content

fix electron v41 regression (webContents is null in destroyed hander)#3057

Merged
sawka merged 2 commits intomainfrom
emain/undefined-error
Mar 13, 2026
Merged

fix electron v41 regression (webContents is null in destroyed hander)#3057
sawka merged 2 commits intomainfrom
emain/undefined-error

Conversation

@sawka
Copy link
Member

@sawka sawka commented Mar 13, 2026

also adds a bit more defensiveness around using webContents.id.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2a08c2c9-d70f-4fdc-911b-2c4e0870ba99

📥 Commits

Reviewing files that changed from the base of the PR and between 1b708ea and 703ac77.

📒 Files selected for processing (3)
  • emain/emain-ipc.ts
  • emain/emain-tabview.ts
  • emain/emain-window.ts

Walkthrough

The changes strengthen null-safety across three Electron main process files (emain-ipc.ts, emain-tabview.ts, emain-window.ts). They introduce defensive null checks for webContents and webContentsId values in window retrieval and lifecycle functions, use local variable caching for repeated property access, and prevent operations on destroyed WebContents instances. One function signature is updated to reflect a nullable return type, and an unused variable is removed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing an Electron v41 regression where webContents can be null in destroyed handlers.
Description check ✅ Passed The description is related to the changeset, noting the addition of defensive checks around webContents.id usage, which aligns with the actual code modifications across the three files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch emain/undefined-error
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 13, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR adds defensive null checks to prevent potential runtime errors in the Electron main process. All changes are valid improvements.

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 0

Changes Reviewed

  • emain/emain-ipc.ts - Added optional chaining and null checks for webContents access
  • emain/emain-tabview.ts - Added null checks for webContentsId parameter and webContents access, improved variable capture for safer cleanup
  • emain/emain-window.ts - Added null check for webContentsId parameter

These changes prevent potential null reference errors that could occur when:

  • hostWebContents is null
  • getWaveWindowByWebContentsId returns null
  • webContents is destroyed
  • Parameters are passed as null/undefined
Files Reviewed (3 files)
  • emain/emain-ipc.ts
  • emain/emain-tabview.ts
  • emain/emain-window.ts

@sawka sawka merged commit 4034526 into main Mar 13, 2026
7 checks passed
@sawka sawka deleted the emain/undefined-error branch March 13, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant