[MM-68740] Guard loading screen fade against undefined webContents - #3922
Merged
devinbinnie merged 1 commit intoJul 30, 2026
Merged
Conversation
Electron can leave WebContentsView.webContents undefined during teardown. LoadingScreen.fade() checked isDestroyed() on it directly, so a fade triggered by setInitialized after teardown threw an unhandled TypeError. Cache the webContents and guard on existence as well as isDestroyed before sending, leaving the FADING state transition untouched so the animation-finished flow is unaffected. Co-authored-by: Nick Misasi <nick13misasi@gmail.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughChangesThe loading screen fade path now safely handles missing or destroyed Loading screen fade lifecycle
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
devinbinnie
approved these changes
Jul 30, 2026
Contributor
Author
|
Merging as the playwright failures are unrelated |
nickmisasi
enabled auto-merge (squash)
July 30, 2026 18:21
devinbinnie
disabled auto-merge
July 30, 2026 18:21
6 tasks
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fixes an unhandled
TypeErrorthrown fromLoadingScreen.fade()when Electron has already torn down the loading screen'swebContents.Electron can leave
WebContentsView.webContentsundefined during teardown.fade()calledisDestroyed()directly on it, so a fade triggered bysetInitializedafter teardown threw. The change caches thewebContentsand guards on existence as well as destroyed-ness before sending:The
this.state = LoadingScreenState.FADINGtransition is deliberately left where it was, ahead of the guard, sohandleAnimationFinishedand the state machine behave exactly as before. Scope is confined tofade().Why the reported signature differs from what reproduces today
Sentry
MATTERMOST-DESKTOP-1SreportsCannot read properties of undefined (reading 'send'), with culpritm.fadereached viaIpcMainImpl → setInitialized → fadeLoadingScreen → fade. Every one of its 2,009 events comes from released 6.1.1–6.2.2 builds, wherefade()calledsend()with no guard at all.e6994098(MM-68749, #3822) later wrapped thatsend()in anisDestroyed()check, which fixed thesendvariant but still assumedwebContentsexists. So onmasterthe same teardown race now throwsCannot read properties of undefined (reading 'isDestroyed')instead — the signature tracked as MM-68927. RevertingloadingScreen.tsand running the new tests reproduces exactly that:Both pass with the fix applied.
Sibling
this.view.webContentsdereferences inshow(),destroy(), andregisterThemeManager()carry the same latent hazard but are intentionally left alone to keep this change minimal.Ticket Link
https://mattermost.atlassian.net/browse/MM-68740
Checklist
npm run lint:jsfor proper code formattingDevice Information
Verified on Linux (x64) via the unit suite only.
npm run checkis green: ESLint andtscclean,Test Suites: 79 passed, 79 total,Tests: 1317 passed, 1317 total.This is a teardown race with no practical manual reproduction, so correctness is demonstrated by the two new regression tests, which fail against the pre-fix code with the exact production crash and pass after it, rather than by manual GUI testing.
Release Note
Change Impact: 🟢 Low
Regression Risk: Low; the change is isolated to loading-screen teardown handling and is covered by regression tests.
QA Recommendation: Manual QA can be skipped; automated coverage is sufficient.
Generated by CodeRabbitAI