diff --git a/packages/cli/src/utils/processUtils.test.ts b/packages/cli/src/utils/processUtils.test.ts index 487c702dc5..9498d94b96 100644 --- a/packages/cli/src/utils/processUtils.test.ts +++ b/packages/cli/src/utils/processUtils.test.ts @@ -26,7 +26,12 @@ describe('processUtils', () => { beforeEach(() => { _resetRelaunchStateForTesting(); - process.send = vi.fn(); + process.send = vi.fn( + (_msg: unknown, callback?: (err: Error | null) => void) => { + if (callback) callback(null); + return true; + }, + ); }); afterEach(() => { @@ -46,10 +51,13 @@ describe('processUtils', () => { await relaunchApp('custom-session-id'); expect(handleAutoUpdate.waitForUpdateCompletion).toHaveBeenCalledTimes(1); expect(runExitCleanup).toHaveBeenCalledTimes(1); - expect(process.send).toHaveBeenCalledWith({ - type: 'relaunch-session', - sessionId: 'custom-session-id', - }); + expect(process.send).toHaveBeenCalledWith( + { + type: 'relaunch-session', + sessionId: 'custom-session-id', + }, + expect.any(Function), + ); expect(processExit).toHaveBeenCalledWith(RELAUNCH_EXIT_CODE); }); }); diff --git a/packages/cli/src/utils/processUtils.ts b/packages/cli/src/utils/processUtils.ts index 9ebb5c2730..5a09c2bb47 100644 --- a/packages/cli/src/utils/processUtils.ts +++ b/packages/cli/src/utils/processUtils.ts @@ -29,9 +29,14 @@ export async function relaunchApp(sessionId?: string): Promise { await runExitCleanup(); if (process.send && sessionId) { - process.send({ - type: 'relaunch-session', - sessionId, + await new Promise((resolve) => { + process.send!( + { + type: 'relaunch-session', + sessionId, + }, + () => resolve(), + ); }); }