Skip to content

Commit 7a71362

Browse files
committed
fix(cli): add error handling to session resume async IIFE
Wrap the async session resume operation in try/catch to prevent unhandled promise rejections. Errors are now reported via coreEvents feedback system, consistent with error handling in useSessionBrowser. Addresses review feedback on google-gemini#16222.
1 parent 3fd1d3f commit 7a71362

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/cli/src/ui/hooks/useSessionResume.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import { useCallback, useEffect, useRef } from 'react';
8+
import { coreEvents } from '@google/gemini-cli-core';
89
import type { Config, ResumedSessionData } from '@google/gemini-cli-core';
910
import type { Part } from '@google/genai';
1011
import type { HistoryItemWithoutId } from '../types.js';
@@ -87,11 +88,15 @@ export function useSessionResume({
8788
// Use async IIFE to properly await the async callback
8889
// This ensures chat is fully initialized before user can send prompts
8990
void (async () => {
90-
await loadHistoryForResume(
91-
historyData.uiHistory,
92-
historyData.clientHistory,
93-
resumedSessionData,
94-
);
91+
try {
92+
await loadHistoryForResume(
93+
historyData.uiHistory,
94+
historyData.clientHistory,
95+
resumedSessionData,
96+
);
97+
} catch (error) {
98+
coreEvents.emitFeedback('error', 'Error resuming session:', error);
99+
}
95100
})();
96101
}
97102
}, [

0 commit comments

Comments
 (0)