fix(patch): cherry-pick bd53951 to release/v0.44.0-pr-27496 [CONFLICTS] (#27534)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
gemini-cli-robot
2026-05-28 09:52:17 -07:00
committed by GitHub
parent 1000b33d4c
commit 73421e3b6f
2 changed files with 50 additions and 27 deletions
+15 -8
View File
@@ -20,14 +20,21 @@ import {
// Suppress known race condition error in node-pty on Windows
// Tracking bug: https://github.com/microsoft/node-pty/issues/827
process.on('uncaughtException', (error) => {
if (
process.platform === 'win32' &&
error instanceof Error &&
error.message === 'Cannot resize a pty that has already exited'
) {
// This error happens on Windows with node-pty when resizing a pty that has just exited.
// It is a race condition in node-pty that we cannot prevent, so we silence it.
return;
if (error instanceof Error) {
const message = error.message || '';
const isPtyResizeError =
message === 'Cannot resize a pty that has already exited';
const isEbadfError =
message.includes('EBADF') ||
(error as { code?: string }).code === 'EBADF';
const isFromNodePty =
error.stack?.includes('node-pty') || error.stack?.includes('PtyResize');
if ((isPtyResizeError || isEbadfError) && isFromNodePty) {
// This error happens with node-pty when resizing a pty that has just exited.
// It is a race condition in node-pty that we cannot prevent, so we silence it.
return;
}
}
// For other errors, we rely on the default behavior, but since we attached a listener,