fix(pty): prevent crash loop when closing app with running processes#679
Merged
rabanspiegel merged 5 commits intomainfrom Jan 21, 2026
Merged
fix(pty): prevent crash loop when closing app with running processes#679rabanspiegel merged 5 commits intomainfrom
rabanspiegel merged 5 commits intomainfrom
Conversation
Guard IPC sends to destroyed WebContents and clean up PTYs on window close to prevent the "Object has been destroyed" crash loop. - Add safeSendToOwner() helper that checks isDestroyed() before sending - Add WebContents destruction listener to kill PTYs when window closes - Add before-quit handler to clean up all PTYs on app shutdown - Guard pty:started broadcast with per-window isDestroyed() check Fixes #676
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Bugbot Autofix prepared a fix for the bug found in the latest run.
|
Move listener outside if-block so each owner gets a listener, but only the current owner's listener triggers cleanup. Prevents both stale listeners killing PTYs and missing cleanup for new owners.
Closed
|
Bugbot Autofix prepared a fix for the bug found in the latest run.
|
…#681) The onExit callback now checks if the PTY is still active before modifying the owners and listeners maps, preventing a race condition where an old PTY's exit could corrupt a new PTY's state when they share the same ID. Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Call maybeMarkProviderFinish before killPty in both the 'destroyed' listener and 'before-quit' handler to ensure telemetry timers are cleared and agent_run_finish events are captured when PTYs are killed during window close or app shutdown, matching the pattern established in the pty:kill handler.
|
Bugbot Autofix prepared a fix for the bug found in the latest run.
|
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
safeSendToOwner()helperbefore-quithandler to clean up all PTYs on app shutdownpty:startedbroadcast with per-windowisDestroyed()checkTest plan
npm run devpty:ownerDestroyedlogs appear in terminal outputFixes #676
Note
Improves PTY lifecycle safety to avoid crashes during window/app shutdown.
safeSendToOwner()to guard IPC sends whenWebContentsis destroyedonData/onExitlisteners that use safe sending and ignore staleonExiteventsWebContentsdestroyedhandler tomaybeMarkProviderFinish(),killPty(), and clear PTY ownership/listener statepty:startedbroadcast by checkingwebContents.isDestroyed()per windowbefore-quit, iterates all PTYs tomaybeMarkProviderFinish(),killPty(), and clearsowners/listenersappfromelectronto support shutdown handlingWritten by Cursor Bugbot for commit 39e7aed. This will update automatically on new commits. Configure here.