Consistently guard restarts against concurrent auto updates (#21016)

This commit is contained in:
Tommaso Sciortino
2026-03-03 22:18:12 -08:00
committed by GitHub
parent bbcfff5cf1
commit 7e06559db2
10 changed files with 48 additions and 31 deletions

View File

@@ -21,9 +21,8 @@ import {
} from '@google/gemini-cli-core';
import { useKeypress } from '../hooks/useKeypress.js';
import { AuthState } from '../types.js';
import { runExitCleanup } from '../../utils/cleanup.js';
import { validateAuthMethodWithSettings } from './useAuth.js';
import { RELAUNCH_EXIT_CODE } from '../../utils/processUtils.js';
import { relaunchApp } from '../../utils/processUtils.js';
interface AuthDialogProps {
config: Config;
@@ -133,10 +132,7 @@ export function AuthDialog({
config.isBrowserLaunchSuppressed()
) {
setExiting(true);
setTimeout(async () => {
await runExitCleanup();
process.exit(RELAUNCH_EXIT_CODE);
}, 100);
setTimeout(relaunchApp, 100);
return;
}

View File

@@ -9,7 +9,10 @@ import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
import { LoginWithGoogleRestartDialog } from './LoginWithGoogleRestartDialog.js';
import { useKeypress } from '../hooks/useKeypress.js';
import { runExitCleanup } from '../../utils/cleanup.js';
import { RELAUNCH_EXIT_CODE } from '../../utils/processUtils.js';
import {
RELAUNCH_EXIT_CODE,
_resetRelaunchStateForTesting,
} from '../../utils/processUtils.js';
import { type Config } from '@google/gemini-cli-core';
// Mocks
@@ -38,6 +41,7 @@ describe('LoginWithGoogleRestartDialog', () => {
vi.clearAllMocks();
exitSpy.mockClear();
vi.useRealTimers();
_resetRelaunchStateForTesting();
});
it('renders correctly', async () => {

View File

@@ -8,8 +8,7 @@ import { type Config } from '@google/gemini-cli-core';
import { Box, Text } from 'ink';
import { theme } from '../semantic-colors.js';
import { useKeypress } from '../hooks/useKeypress.js';
import { runExitCleanup } from '../../utils/cleanup.js';
import { RELAUNCH_EXIT_CODE } from '../../utils/processUtils.js';
import { relaunchApp } from '../../utils/processUtils.js';
interface LoginWithGoogleRestartDialogProps {
onDismiss: () => void;
@@ -36,8 +35,7 @@ export const LoginWithGoogleRestartDialog = ({
});
}
}
await runExitCleanup();
process.exit(RELAUNCH_EXIT_CODE);
await relaunchApp();
}, 100);
return true;
}