Protect stdout and stderr so JavaScript code can't accidentally write to stdout corrupting ink rendering (#13247)

Bypassing rules as link checker failure is spurious.
This commit is contained in:
Jacob Richman
2025-11-20 10:44:02 -08:00
committed by GitHub
parent e20d282088
commit d1e35f8660
82 changed files with 1523 additions and 868 deletions
+10
View File
@@ -17,6 +17,7 @@ import {
FatalToolExecutionError,
isFatalToolError,
} from '@google/gemini-cli-core';
import { runSyncCleanup } from './cleanup.js';
export function getErrorMessage(error: unknown): string {
if (error instanceof Error) {
@@ -90,6 +91,7 @@ export function handleError(
stats: streamFormatter.convertToStreamStats(metrics, 0),
});
runSyncCleanup();
process.exit(getNumericExitCode(errorCode));
} else if (config.getOutputFormat() === OutputFormat.JSON) {
const formatter = new JsonFormatter();
@@ -101,6 +103,7 @@ export function handleError(
);
console.error(formattedError);
runSyncCleanup();
process.exit(getNumericExitCode(errorCode));
} else {
console.error(errorMessage);
@@ -154,6 +157,7 @@ export function handleToolError(
} else {
console.error(errorMessage);
}
runSyncCleanup();
process.exit(toolExecutionError.exitCode);
}
@@ -180,6 +184,7 @@ export function handleCancellationError(config: Config): never {
},
stats: streamFormatter.convertToStreamStats(metrics, 0),
});
runSyncCleanup();
process.exit(cancellationError.exitCode);
} else if (config.getOutputFormat() === OutputFormat.JSON) {
const formatter = new JsonFormatter();
@@ -189,9 +194,11 @@ export function handleCancellationError(config: Config): never {
);
console.error(formattedError);
runSyncCleanup();
process.exit(cancellationError.exitCode);
} else {
console.error(cancellationError.message);
runSyncCleanup();
process.exit(cancellationError.exitCode);
}
}
@@ -217,6 +224,7 @@ export function handleMaxTurnsExceededError(config: Config): never {
},
stats: streamFormatter.convertToStreamStats(metrics, 0),
});
runSyncCleanup();
process.exit(maxTurnsError.exitCode);
} else if (config.getOutputFormat() === OutputFormat.JSON) {
const formatter = new JsonFormatter();
@@ -226,9 +234,11 @@ export function handleMaxTurnsExceededError(config: Config): never {
);
console.error(formattedError);
runSyncCleanup();
process.exit(maxTurnsError.exitCode);
} else {
console.error(maxTurnsError.message);
runSyncCleanup();
process.exit(maxTurnsError.exitCode);
}
}