mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 13:04:49 -07:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user