fix(cli): Fix performance issues on relaunching CLI in inner node pro… (#8571)

This commit is contained in:
shrutip90
2025-09-16 14:47:45 -07:00
committed by GitHub
parent a0079785af
commit 20ad40092c

View File

@@ -106,16 +106,33 @@ function getNodeMemoryArgs(config: Config): string[] {
}
async function relaunchWithAdditionalArgs(additionalArgs: string[]) {
const nodeArgs = [...additionalArgs, ...process.argv.slice(1)];
const newEnv = { ...process.env, GEMINI_CLI_NO_RELAUNCH: 'true' };
try {
const nodeArgs = [...additionalArgs, ...process.argv.slice(1)];
const newEnv = { ...process.env, GEMINI_CLI_NO_RELAUNCH: 'true' };
const child = spawn(process.execPath, nodeArgs, {
stdio: 'inherit',
env: newEnv,
});
// The parent process should not be reading from stdin while the child is running.
process.stdin.pause();
await new Promise((resolve) => child.on('close', resolve));
process.exit(0);
const child = spawn(process.execPath, nodeArgs, {
stdio: 'inherit',
env: newEnv,
});
await new Promise<void>((resolve, reject) => {
child.on('error', reject);
child.on('close', () => {
// Resume stdin before the parent process exits.
process.stdin.resume();
resolve();
});
});
process.exit(0);
} catch (error) {
process.stdin.resume();
console.error('Failed to relaunch CLI:', error);
process.exit(1);
}
}
import { runZedIntegration } from './zed-integration/zedIntegration.js';