mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-11 06:31:01 -07:00
drain stdin on exit (#17241)
This commit is contained in:
committed by
GitHub
parent
a91665db40
commit
dce450b1e8
@@ -55,6 +55,10 @@ export function registerTelemetryConfig(config: Config) {
|
||||
}
|
||||
|
||||
export async function runExitCleanup() {
|
||||
// drain stdin to prevent printing garbage on exit
|
||||
// https://github.com/google-gemini/gemini-cli/issues/1680
|
||||
await drainStdin();
|
||||
|
||||
runSyncCleanup();
|
||||
for (const fn of cleanupFunctions) {
|
||||
try {
|
||||
@@ -84,6 +88,18 @@ export async function runExitCleanup() {
|
||||
}
|
||||
}
|
||||
|
||||
async function drainStdin() {
|
||||
if (!process.stdin?.isTTY) return;
|
||||
// Resume stdin and attach a no-op listener to drain the buffer.
|
||||
// We use removeAllListeners to ensure we don't trigger other handlers.
|
||||
process.stdin
|
||||
.resume()
|
||||
.removeAllListeners('data')
|
||||
.on('data', () => {});
|
||||
// Give it a moment to flush the OS buffer.
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
}
|
||||
|
||||
export async function cleanupCheckpoints() {
|
||||
const storage = new Storage(process.cwd());
|
||||
const tempDir = storage.getProjectTempDir();
|
||||
|
||||
Reference in New Issue
Block a user