fix(core): quitting waits for every shell to be gone, on node-pty 1.2.0-beta.15 (#127) - #128
Merged
Merged
Conversation
….0-beta.15 (#127) Closing the app with several shells could crash it at quit, two ways, both measured. node-pty 1.1.0's exit threads raced on an unlocked vector and asserted (the owner's "Assertion failed! remove_pty_baton" dialog), fixed upstream in #922, so node-pty is pinned to 1.2.0-beta.15. And an exit callback landing while Node tears down threw and Electron aborted (0xc0000409, about one quit in four with ten shells; WER dump: FreeEnvironment -> ThreadSafeFunction::CallJS -> abort). Every kill now goes through killPty, and will-quit holds the quit on shellsGone (3 s cap) while a shell is dying, reading the agent's exitCode, set by the native callback, rather than the exit event that lags 1-2.7 s for a warm shell. The quitManyShells e2e quits with ten shells three times and needs a clean exit 0; it failed on both node-pty versions without the wait. Core 0.23.1, app 0.28.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FHHaWKR4M5QtW7Wecyuk4t
github-actions Bot
pushed a commit
that referenced
this pull request
Oct 4, 2026
….0-beta.15 (#127) (#128) Closing the app with several shells could crash it at quit, two ways, both measured. node-pty 1.1.0's exit threads raced on an unlocked vector and asserted (the owner's "Assertion failed! remove_pty_baton" dialog), fixed upstream in #922, so node-pty is pinned to 1.2.0-beta.15. And an exit callback landing while Node tears down threw and Electron aborted (0xc0000409, about one quit in four with ten shells; WER dump: FreeEnvironment -> ThreadSafeFunction::CallJS -> abort). Every kill now goes through killPty, and will-quit holds the quit on shellsGone (3 s cap) while a shell is dying, reading the agent's exitCode, set by the native callback, rather than the exit event that lags 1-2.7 s for a warm shell. The quitManyShells e2e quits with ten shells three times and needs a clean exit 0; it failed on both node-pty versions without the wait. Core 0.23.1, app 0.28.3. Claude-Session: https://claude.ai/code/session_01FHHaWKR4M5QtW7Wecyuk4t Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #127.
What you saw: "Assertion failed! conpty.node ... remove_pty_baton(baton->id)" when the stable copy was closed for an update.
Two crashes at quit, both measured:
node-ptyis pinned to1.2.0-beta.15, the owner's pick. Itsconpty.nodeno longer contains the assert.node::FreeEnvironment->CleanupHandles->ThreadSafeFunction::CallJS->Napi::Error->abort: a shell's exit callback landed while Node was tearing down.Fix (core):
killPty, which remembers the shell until it has exited.will-quitholds the quit onshellsGone(3000), but only while a shell is actually dying. A hold that ended at once lost the follow-upapp.quit()and left the app running; theopacityAlphae2e caught that.exitCode, which the native callback sets, not the exit event. The event lags 1 to 2.7 s for a pwsh killed mid-start (a warm shell). Quit stays at about 0.15 s.Prism: gets the quit wait through the core bump. Its own node-pty upgrade will be a separate Prism PR.
Gate:
quitManyShells(ten shells, quit, three rounds, must exit 0 by itself): 24 of 24 rounds clean with the fix. Without it: 1 crash in 6 rounds on 1.1.0, 4 in 12 on the beta.Core 0.23.1, app 0.28.3.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FHHaWKR4M5QtW7Wecyuk4t