Skip to content

Fix/windows pty crash#12587

Merged
bdmorgan merged 10 commits into
mainfrom
fix/windows-pty-crash
Nov 5, 2025
Merged

Fix/windows pty crash#12587
bdmorgan merged 10 commits into
mainfrom
fix/windows-pty-crash

Conversation

@bdmorgan

@bdmorgan bdmorgan commented Nov 5, 2025

Copy link
Copy Markdown
Collaborator

These are fixes for PR #11559

LayorX and others added 8 commits November 4, 2025 08:51
On Windows, a race condition can occur where a resize event is processed for a pseudo-terminal (pty) that has already exited. This was throwing an unhandled error, 'Cannot resize a pty that has already exited,' causing the entire CLI process to crash.

The existing error handling in resizePty only checked for the ESRCH error code, which is specific to Unix-like systems.

This change updates the catch block to also identify the Windows-specific error message, allowing the error to be safely ignored in the same way as its Unix counterpart. This improves the stability of shell command execution on Windows, especially for short-lived commands.
This commit introduces a 	ry...catch block around the ShellExecutionService.resizePty call within AppContainer.tsx.

This acts as a safeguard to prevent the UI from crashing if the underlying pty process exits unexpectedly before the resize operation can complete. This change provides an additional layer of resilience and prevents the entire CLI from terminating due to this specific race condition on Windows.
Adds two regression tests to ensure the CLI does not crash when a pty process exits before a resize operation can be performed. This scenario was causing crashes on Windows.

- A test in `AppContainer.test.tsx` simulates the error being thrown during a render cycle and asserts that the component does not crash.
- A test in `shellExecutionService.test.ts` directly tests the `resizePty` method, ensuring it catches the specific error and does not re-throw it.

This addresses the feedback from the pull request review to ensure the fix is robust and prevents future regressions.
@bdmorgan bdmorgan requested a review from a team as a code owner November 5, 2025 16:32
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @bdmorgan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces critical fixes to address a specific crash scenario on Windows where the application would fail when attempting to resize a pseudo-terminal (pty) that had already terminated. By implementing robust error handling and adding targeted tests, the changes significantly improve the stability and resilience of the application, particularly for users on Windows operating systems, ensuring a smoother user experience.

Highlights

  • Windows PTY Crash Fix: Implemented robust error handling in AppContainer and ShellExecutionService to prevent application crashes when attempting to resize a pseudo-terminal (pty) that has already exited, specifically addressing a Windows-specific error message.
  • Enhanced Error Handling Logic: The resizePty method now explicitly checks for and ignores the Windows-specific error message "Cannot resize a pty that has already exited", in addition to the existing ESRCH error for Unix-like systems, ensuring graceful failure in race conditions.
  • Improved Test Coverage and Stability: Added new test cases in AppContainer.test.tsx and shellExecutionService.test.ts to verify that the UI and service layers correctly handle pty resize failures without crashing. Several test files also had timeouts increased or tests skipped on Windows to account for platform-specific behaviors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a crash on Windows that occurs when trying to resize a PTY that has already exited. The fix involves adding error handling to gracefully manage this race condition. The changes are sound and include necessary test updates. However, I've identified a redundant try-catch block in AppContainer.tsx, as the error is already handled within the ShellExecutionService. Removing this duplication will improve code clarity and maintainability. I've also suggested a small refactoring in shellExecutionService.ts to simplify an if condition. The other changes, mostly related to test timeouts and configurations, appear reasonable.

Comment thread packages/cli/src/ui/AppContainer.tsx
Comment thread packages/core/src/services/shellExecutionService.ts Outdated
@github-actions

github-actions Bot commented Nov 5, 2025

Copy link
Copy Markdown

Size Change: +229 B (0%)

Total Size: 20.4 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 20.4 MB +229 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@bdmorgan bdmorgan mentioned this pull request Nov 5, 2025
@skeshive skeshive self-requested a review November 5, 2025 16:50
@bdmorgan bdmorgan added this pull request to the merge queue Nov 5, 2025
Merged via the queue into main with commit 1611364 Nov 5, 2025
22 checks passed
@bdmorgan bdmorgan deleted the fix/windows-pty-crash branch November 5, 2025 17:03
@LayorX

LayorX commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

Finally !! Thx

@skeshive

skeshive commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

/patch preview

@github-actions

github-actions Bot commented Nov 5, 2025

Copy link
Copy Markdown

Patch workflow(s) dispatched successfully!

📋 Details:

  • Channels: preview
  • Commit: 16113647de09b49297eee1206460b2247d6a38a4
  • Workflows Created: 1

🔗 Track Progress:

github-actions Bot pushed a commit that referenced this pull request Nov 5, 2025
Co-authored-by: LayorX <yor31117@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 5, 2025

Copy link
Copy Markdown

🚀 Patch PR Created!

📋 Patch Details:

📝 Next Steps:

  1. Review and approve the hotfix PR: #12601
  2. Once merged, the patch release will automatically trigger
  3. You'll receive updates here when the release completes

🔗 Track Progress:

@github-actions

github-actions Bot commented Nov 5, 2025

Copy link
Copy Markdown

🚀 Patch Release Started!

📋 Release Details:

  • Environment: prod
  • Channel: preview → publishing to npm tag preview
  • Version: v0.13.0-preview.1
  • Hotfix PR: Merged ✅
  • Release Branch: release/v0.13.0-preview.1-pr-12587

⏳ Status: The patch release is now running. You'll receive another update when it completes.

🔗 Track Progress:

@github-actions

github-actions Bot commented Nov 5, 2025

Copy link
Copy Markdown

Patch Release Complete!

📦 Release Details:

🎉 Status: Your patch has been successfully released and published to npm!

📝 What's Available:

🔗 Links:

thacio added a commit to thacio/auditaria that referenced this pull request Nov 6, 2025
danpalmer pushed a commit to danpalmer/gemini-cli that referenced this pull request Nov 29, 2025
Co-authored-by: LayorX <yor31117@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Zhihong0321

Copy link
Copy Markdown

NO SUCH THING. IT NEVER FIXED.
SINCE OCT TILL NOW DEC 2025

IT NEVER FIXED.
image

cocosheng-g pushed a commit that referenced this pull request May 6, 2026
Co-authored-by: LayorX <yor31117@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants