{
"issue": {
"url": "https://api.github.com/repos/laurent22/joplin/issues/14689",
"repository_url": "https://api.github.com/repos/laurent22/joplin",
"labels_url": "https://api.github.com/repos/laurent22/joplin/issues/14689/labels{/name}",
"comments_url": "https://api.github.com/repos/laurent22/joplin/issues/14689/comments",
"events_url": "https://api.github.com/repos/laurent22/joplin/issues/14689/events",
"html_url": "https://github.com/laurent22/joplin/pull/14689",
"id": 4055450903,
"node_id": "PR_kwDOBLftOs7JkXhW",
"number": 14689,
"title": "Desktop: Fixes #14687: Prevent TypeError in handleAppFailure when window is destroyed",
"user": {
"login": "Ehtesham-Zahid",
"id": 98094052,
"node_id": "U_kgDOBdjL5A",
"avatar_url": "https://avatars.githubusercontent.com/u/98094052?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Ehtesham-Zahid",
"html_url": "https://github.com/Ehtesham-Zahid",
"followers_url": "https://api.github.com/users/Ehtesham-Zahid/followers",
"following_url": "https://api.github.com/users/Ehtesham-Zahid/following{/other_user}",
"gists_url": "https://api.github.com/users/Ehtesham-Zahid/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Ehtesham-Zahid/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Ehtesham-Zahid/subscriptions",
"organizations_url": "https://api.github.com/users/Ehtesham-Zahid/orgs",
"repos_url": "https://api.github.com/users/Ehtesham-Zahid/repos",
"events_url": "https://api.github.com/users/Ehtesham-Zahid/events{/privacy}",
"received_events_url": "https://api.github.com/users/Ehtesham-Zahid/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"labels": [
{
"id": 519700741,
"node_id": "MDU6TGFiZWw1MTk3MDA3NDE=",
"url": "https://api.github.com/repos/laurent22/joplin/labels/bug",
"name": "bug",
"color": "cf353b",
"default": true,
"description": "It's a bug"
},
{
"id": 1080341216,
"node_id": "MDU6TGFiZWwxMDgwMzQxMjE2",
"url": "https://api.github.com/repos/laurent22/joplin/labels/desktop",
"name": "desktop",
"color": "ffc274",
"default": false,
"description": "All desktop platforms"
}
],
"state": "closed",
"locked": false,
"assignees": [],
"milestone": null,
"comments": 3,
"created_at": "2026-03-11T03:17:32Z",
"updated_at": "2026-03-14T12:49:30Z",
"closed_at": "2026-03-14T12:44:11Z",
"assignee": null,
"author_association": "CONTRIBUTOR",
"active_lock_reason": null,
"draft": false,
"pull_request": {
"url": "https://api.github.com/repos/laurent22/joplin/pulls/14689",
"html_url": "https://github.com/laurent22/joplin/pull/14689",
"diff_url": "https://github.com/laurent22/joplin/pull/14689.diff",
"patch_url": "https://github.com/laurent22/joplin/pull/14689.patch",
"merged_at": "2026-03-14T12:44:10Z"
},
"body": "## Problem\r\nFixes #14687\r\n\r\nOn Windows environments (observed during Electron 39 testing), a violent renderer process crash triggers the `handleAppFailure` recovery dialog. While the application successfully initiates a restart when the user selects \"Restart in safe mode,\" a race condition exists during the process teardown.\r\n\r\nBy the time the restart logic attempts to forcefully crash the old renderer to ensure a clean exit, the `BrowserWindow` object has often been destroyed asynchronously by the system. Accessing `this.win_.webContents` at this stage throws a `TypeError: Object has been destroyed`, leading to an unhandled promise rejection in the Main Process. While the app re-opens, this error indicates an unstable teardown and can mask other critical logs during a failure event.\r\n\r\n## Solution\r\nI have implemented defensive guard clauses using the Electron `isDestroyed()` API to harden the failure path:\r\n\r\n1. **Entry Guard:** Added a check at the start of `handleAppFailure`. If the window is already destroyed (due to a violent crash or multiple triggers), the error is captured via the `bridge().captureException` service for logging, and the function returns gracefully.\r\n2. **Restart Guard:** Added a check within the \"Restart in safe mode\" logic. We now verify that `this.win_` is not destroyed before attempting to access `webContents.forcefullyCrashRenderer()`.\r\n\r\nThese changes ensure the Main Process remains stable during recovery and completes the handover to the new process without unhandled exceptions.\r\n\r\n*Note: This is a GSoC 2026 contribution. AI was used to assist in refining the Jest test mocks and environment troubleshooting.*\r\n\r\n## Test Plan\r\n\r\n### Manual Verification\r\nTested on Windows 11 using a development build. \r\n1. Triggered a renderer crash (assertion failure).\r\n2. Confirmed the recovery dialog appeared.\r\n3. Selected \"Restart in safe mode.\"\r\n4. Verified that the app successfully restarted and the terminal logs no longer showed the `TypeError: Object has been destroyed` or unhandled promise rejection.\r\n\r\n### Automated Test\r\nAdded `packages/app-desktop/ElectronAppWrapper.test.ts`. \r\n- This test utilizes a stateful mock to simulate a window that is valid at the handler's entry but becomes destroyed before the restart cleanup logic executes.\r\n- Verified the fix prevents the exception and allows the function to resolve.\r\n\r\n**Run Command:**\r\n`yarn jest ElectronAppWrapper.test.ts`\r\n\r\n## Video\r\nhttps://www.loom.com/share/f8596558952443f7a0645a02825510a3",
"closed_by": {
"login": "laurent22",
"id": 1285584,
"node_id": "MDQ6VXNlcjEyODU1ODQ=",
"avatar_url": "https://avatars.githubusercontent.com/u/1285584?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/laurent22",
"html_url": "https://github.com/laurent22",
"followers_url": "https://api.github.com/users/laurent22/followers",
"following_url": "https://api.github.com/users/laurent22/following{/other_user}",
"gists_url": "https://api.github.com/users/laurent22/gists{/gist_id}",
"starred_url": "https://api.github.com/users/laurent22/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/laurent22/subscriptions",
"organizations_url": "https://api.github.com/users/laurent22/orgs",
"repos_url": "https://api.github.com/users/laurent22/repos",
"events_url": "https://api.github.com/users/laurent22/events{/privacy}",
"received_events_url": "https://api.github.com/users/laurent22/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"reactions": {
"url": "https://api.github.com/repos/laurent22/joplin/issues/14689/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"timeline_url": "https://api.github.com/repos/laurent22/joplin/issues/14689/timeline",
"performed_via_github_app": null,
"state_reason": null
},
"comments": [
{
"url": "https://api.github.com/repos/laurent22/joplin/issues/comments/4035925722",
"html_url": "https://github.com/laurent22/joplin/pull/14689#issuecomment-4035925722",
"issue_url": "https://api.github.com/repos/laurent22/joplin/issues/14689",
"id": 4035925722,
"node_id": "IC_kwDOBLftOs7wj1ba",
"user": {
"login": "github-actions[bot]",
"id": 41898282,
"node_id": "MDM6Qm90NDE4OTgyODI=",
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/github-actions%5Bbot%5D",
"html_url": "https://github.com/apps/github-actions",
"followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
"type": "Bot",
"user_view_type": "public",
"site_admin": false
},
"created_at": "2026-03-11T03:17:43Z",
"updated_at": "2026-03-14T12:49:30Z",
"body": "****CLA Assistant Lite bot**** All contributors have signed the CLA βοΈ β
",
"author_association": "CONTRIBUTOR",
"reactions": {
"url": "https://api.github.com/repos/laurent22/joplin/issues/comments/4035925722/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"performed_via_github_app": {
"id": 15368,
"client_id": "Iv1.05c79e9ad1f6bdfa",
"slug": "github-actions",
"node_id": "MDM6QXBwMTUzNjg=",
"owner": {
"login": "github",
"id": 9919,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
"avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/github",
"html_url": "https://github.com/github",
"followers_url": "https://api.github.com/users/github/followers",
"following_url": "https://api.github.com/users/github/following{/other_user}",
"gists_url": "https://api.github.com/users/github/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github/subscriptions",
"organizations_url": "https://api.github.com/users/github/orgs",
"repos_url": "https://api.github.com/users/github/repos",
"events_url": "https://api.github.com/users/github/events{/privacy}",
"received_events_url": "https://api.github.com/users/github/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"name": "GitHub Actions",
"description": "Automate your workflow from idea to production",
"external_url": "https://help.github.com/en/actions",
"html_url": "https://github.com/apps/github-actions",
"created_at": "2018-07-30T09:30:17Z",
"updated_at": "2026-05-05T14:51:38Z",
"permissions": {
"actions": "write",
"administration": "read",
"artifact_metadata": "write",
"attestations": "write",
"checks": "write",
"code_quality": "write",
"contents": "write",
"copilot_requests": "write",
"deployments": "write",
"discussions": "write",
"issues": "write",
"merge_queues": "write",
"metadata": "read",
"models": "read",
"packages": "write",
"pages": "write",
"pull_requests": "write",
"repository_hooks": "write",
"repository_projects": "write",
"security_events": "write",
"statuses": "write",
"vulnerability_alerts": "read"
},
"events": [
"branch_protection_rule",
"check_run",
"check_suite",
"create",
"delete",
"deployment",
"deployment_status",
"discussion",
"discussion_comment",
"fork",
"gollum",
"issues",
"issue_comment",
"label",
"merge_group",
"milestone",
"page_build",
"public",
"pull_request",
"pull_request_review",
"pull_request_review_comment",
"push",
"registry_package",
"release",
"repository",
"repository_dispatch",
"status",
"watch",
"workflow_dispatch",
"workflow_run"
]
}
},
{
"url": "https://api.github.com/repos/laurent22/joplin/issues/comments/4035926550",
"html_url": "https://github.com/laurent22/joplin/pull/14689#issuecomment-4035926550",
"issue_url": "https://api.github.com/repos/laurent22/joplin/issues/14689",
"id": 4035926550,
"node_id": "IC_kwDOBLftOs7wj1oW",
"user": {
"login": "coderabbitai[bot]",
"id": 136622811,
"node_id": "BOT_kgDOCCSy2w",
"avatar_url": "https://avatars.githubusercontent.com/in/347564?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/coderabbitai%5Bbot%5D",
"html_url": "https://github.com/apps/coderabbitai",
"followers_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/coderabbitai%5Bbot%5D/received_events",
"type": "Bot",
"user_view_type": "public",
"site_admin": false
},
"created_at": "2026-03-11T03:17:58Z",
"updated_at": "2026-03-11T04:34:26Z",
"body": "\nNo actionable comments were generated in the recent review. π\n\n\nβΉοΈ Recent review info
\n\n\nβοΈ Run configuration
\n\n**Configuration used**: Path: .coderabbit.yaml\n\n**Review profile**: CHILL\n\n**Plan**: Pro\n\n**Run ID**: `e21eb025-ffb4-4187-bb6a-b8a5799e7bac`\n\n \n\n\nπ₯ Commits
\n\nReviewing files that changed from the base of the PR and between 676d290d980ab214cbd19ac7cef3e15a5e47368d and eba493c4c81572a1498709c59251156e640aea9a.\n\n \n\n\nπ Files selected for processing (2)
\n\n* `.eslintignore`\n* `.gitignore`\n\n \n\n\nβ
Files skipped from review due to trivial changes (2)
\n\n* .gitignore\n* .eslintignore\n\n \n\n \n\n---\n\n\n\n\n\nπ Walkthrough
\n\n## Walkthrough\n\nAdds defensive checks in ElectronAppWrapper.handleAppFailure to avoid accessing a destroyed BrowserWindow during restart, a Jest test that reproduces the race condition and verifies no exception is thrown, and updates ignore lists for the generated test artifact.\n\n## Changes\n\n|Cohort / File(s)|Summary|\n|---|---|\n|**Window Destruction Guards**
`packages/app-desktop/ElectronAppWrapper.ts`|Added early-return guard and additional `isDestroyed()` checks in `handleAppFailure` to prevent calling `webContents.forcefullyCrashRenderer()` when the main window has been destroyed.|\n|**Test Coverage**
`packages/app-desktop/ElectronAppWrapper.test.ts`|New test that mocks bridge/electron and restart utilities, injects a mock window with controlled destruction timing, and asserts `handleAppFailure` resolves without throwing and that `forcefullyCrashRenderer` is not called when the window is destroyed after selecting restart in safe mode.|\n|**Ignore Lists**
`/.eslintignore`, `/.gitignore` (entries: `packages/app-desktop/ElectronAppWrapper.test.js`)|Added ignore entries for the generated test artifact file to prevent linting/tracking of the transpiled test output.|\n\n## Suggested labels\n\nbug, desktop\n\n \n\n\n\n\n\n\n\nπ₯ Pre-merge checks | β
6
\n\n\nβ
Passed checks (6 passed)
\n\n| Check name | Status | Explanation |\n| :-----------------------------------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| Title check | β
Passed | The title accurately describes the main fix: preventing a TypeError in handleAppFailure when the window is destroyed, directly addressing issue `#14687`. |\n| Description check | β
Passed | The description clearly relates to the changeset, detailing the problem, solution, and testing approach for the window destruction race condition fix. |\n| Linked Issues check | β
Passed | The code changes fully address issue `#14687` by implementing defensive guard clauses using isDestroyed() at both entry and restart points, preventing TypeError when accessing destroyed window objects. |\n| Out of Scope Changes check | β
Passed | All changes are scoped to fixing the race condition: ElectronAppWrapper.ts guards, test file addition, and configuration file updates (.eslintignore, .gitignore) for the new test. |\n| Docstring Coverage | β
Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |\n| Pr Description Must Follow Guidelines | β
Passed | The pull request description includes all three required sections: comprehensive problem statement, high-level solution explanation, and detailed test plan. |\n\n \n\nβοΈ Tip: You can configure your own custom pre-merge checks in the settings.\n\n \n\n\n\n\n\n\nβ¨ Finishing Touches
\n\n\nπ§ͺ Generate unit tests (beta)
\n\n- [ ] Create PR with unit tests\n- [ ] Post copyable unit tests in a comment\n\n \n\n \n\n\n\n\n\n---\n\nThanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=laurent22/joplin&utm_content=14689)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n\nβ€οΈ Share
\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n \n\nComment `@coderabbitai help` to get the list of available commands and usage tips.\n\n\n\n\n\n\n\n\n",
"author_association": "CONTRIBUTOR",
"reactions": {
"url": "https://api.github.com/repos/laurent22/joplin/issues/comments/4035926550/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"performed_via_github_app": {
"id": 347564,
"client_id": "Iv1.6aaafe4fe882736b",
"slug": "coderabbitai",
"node_id": "A_kwHOB96YWc4ABU2s",
"owner": {
"login": "coderabbitai",
"id": 132028505,
"node_id": "O_kgDOB96YWQ",
"avatar_url": "https://avatars.githubusercontent.com/u/132028505?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/coderabbitai",
"html_url": "https://github.com/coderabbitai",
"followers_url": "https://api.github.com/users/coderabbitai/followers",
"following_url": "https://api.github.com/users/coderabbitai/following{/other_user}",
"gists_url": "https://api.github.com/users/coderabbitai/gists{/gist_id}",
"starred_url": "https://api.github.com/users/coderabbitai/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/coderabbitai/subscriptions",
"organizations_url": "https://api.github.com/users/coderabbitai/orgs",
"repos_url": "https://api.github.com/users/coderabbitai/repos",
"events_url": "https://api.github.com/users/coderabbitai/events{/privacy}",
"received_events_url": "https://api.github.com/users/coderabbitai/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"name": "coderabbitai",
"description": "# Transforming Code Reviews with AI\r\n\r\n## Features\r\n\r\n**Automated Reviews**: Continuous reviews of the pull requests including incremental commits. \r\n\r\n**Summarization**: Generates high-level summary and a technical walkthrough of the PR changes.Β \r\n\r\n**Line-by-line review**: Provides line-by-line suggestions committable with one click.\r\n\r\n**Codebase verification**: Verifies the impact on the overall codebase and identifies missing changes.\r\n\r\n**Insights into your code**: Ask any questions on your codebase within the pull request \r\n\r\n**Chat about your code** : Chat with the bot around your code.Β The more you chat, the smarter it gets.\r\n\r\n**Issue Validation**: Validates the PR against the linked issues and identifies other related issuesΒ \r\n\r\n\r\n\r\n",
"external_url": "https://coderabbit.ai?utm_source=cr_app&utm_medium=github",
"html_url": "https://github.com/apps/coderabbitai",
"created_at": "2023-06-14T15:47:27Z",
"updated_at": "2026-03-14T07:58:44Z",
"permissions": {
"actions": "read",
"checks": "write",
"contents": "write",
"discussions": "read",
"issues": "write",
"members": "read",
"metadata": "read",
"pull_requests": "write",
"statuses": "write"
},
"events": [
"issues",
"issue_comment",
"label",
"organization",
"pull_request",
"pull_request_review",
"pull_request_review_comment",
"pull_request_review_thread",
"release",
"repository"
]
}
},
{
"url": "https://api.github.com/repos/laurent22/joplin/issues/comments/4035954282",
"html_url": "https://github.com/laurent22/joplin/pull/14689#issuecomment-4035954282",
"issue_url": "https://api.github.com/repos/laurent22/joplin/issues/14689",
"id": 4035954282,
"node_id": "IC_kwDOBLftOs7wj8Zq",
"user": {
"login": "Ehtesham-Zahid",
"id": 98094052,
"node_id": "U_kgDOBdjL5A",
"avatar_url": "https://avatars.githubusercontent.com/u/98094052?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Ehtesham-Zahid",
"html_url": "https://github.com/Ehtesham-Zahid",
"followers_url": "https://api.github.com/users/Ehtesham-Zahid/followers",
"following_url": "https://api.github.com/users/Ehtesham-Zahid/following{/other_user}",
"gists_url": "https://api.github.com/users/Ehtesham-Zahid/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Ehtesham-Zahid/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Ehtesham-Zahid/subscriptions",
"organizations_url": "https://api.github.com/users/Ehtesham-Zahid/orgs",
"repos_url": "https://api.github.com/users/Ehtesham-Zahid/repos",
"events_url": "https://api.github.com/users/Ehtesham-Zahid/events{/privacy}",
"received_events_url": "https://api.github.com/users/Ehtesham-Zahid/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"created_at": "2026-03-11T03:23:44Z",
"updated_at": "2026-03-11T03:23:44Z",
"body": "I have read the CLA Document and I hereby sign the CLA",
"author_association": "CONTRIBUTOR",
"reactions": {
"url": "https://api.github.com/repos/laurent22/joplin/issues/comments/4035954282/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"performed_via_github_app": null
}
]
}