mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-17 09:30:58 -07:00
Consistently guard restarts against concurrent auto updates (#21016)
This commit is contained in:
committed by
GitHub
parent
bbcfff5cf1
commit
7e06559db2
@@ -5,7 +5,11 @@
|
||||
*/
|
||||
|
||||
import { vi } from 'vitest';
|
||||
import { RELAUNCH_EXIT_CODE, relaunchApp } from './processUtils.js';
|
||||
import {
|
||||
RELAUNCH_EXIT_CODE,
|
||||
relaunchApp,
|
||||
_resetRelaunchStateForTesting,
|
||||
} from './processUtils.js';
|
||||
import * as cleanup from './cleanup.js';
|
||||
import * as handleAutoUpdate from './handleAutoUpdate.js';
|
||||
|
||||
@@ -19,6 +23,10 @@ describe('processUtils', () => {
|
||||
.mockReturnValue(undefined as never);
|
||||
const runExitCleanup = vi.spyOn(cleanup, 'runExitCleanup');
|
||||
|
||||
beforeEach(() => {
|
||||
_resetRelaunchStateForTesting();
|
||||
});
|
||||
|
||||
afterEach(() => vi.clearAllMocks());
|
||||
|
||||
it('should wait for updates, run cleanup, and exit with the relaunch code', async () => {
|
||||
|
||||
@@ -15,7 +15,16 @@ export const RELAUNCH_EXIT_CODE = 199;
|
||||
/**
|
||||
* Exits the process with a special code to signal that the parent process should relaunch it.
|
||||
*/
|
||||
let isRelaunching = false;
|
||||
|
||||
/** @internal only for testing */
|
||||
export function _resetRelaunchStateForTesting(): void {
|
||||
isRelaunching = false;
|
||||
}
|
||||
|
||||
export async function relaunchApp(): Promise<void> {
|
||||
if (isRelaunching) return;
|
||||
isRelaunching = true;
|
||||
await waitForUpdateCompletion();
|
||||
await runExitCleanup();
|
||||
process.exit(RELAUNCH_EXIT_CODE);
|
||||
|
||||
Reference in New Issue
Block a user