mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-28 22:14:52 -07:00
fix(core): gracefully handle disk full errors in chat recording (#17305)
Co-authored-by: RUiNtheExtinct <deepkarma001@gmail.com> Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
@@ -20,6 +20,14 @@ import type { ToolResultDisplay } from '../tools/tools.js';
|
||||
|
||||
export const SESSION_FILE_PREFIX = 'session-';
|
||||
|
||||
/**
|
||||
* Warning message shown when recording is disabled due to disk full.
|
||||
*/
|
||||
const ENOSPC_WARNING_MESSAGE =
|
||||
'Chat recording disabled: No space left on device. ' +
|
||||
'The conversation will continue but will not be saved to disk. ' +
|
||||
'Free up disk space and restart to enable recording.';
|
||||
|
||||
/**
|
||||
* Token usage summary for a message or conversation.
|
||||
*/
|
||||
@@ -173,6 +181,16 @@ export class ChatRecordingService {
|
||||
this.queuedThoughts = [];
|
||||
this.queuedTokens = null;
|
||||
} catch (error) {
|
||||
// Handle disk full (ENOSPC) gracefully - disable recording but allow CLI to continue
|
||||
if (
|
||||
error instanceof Error &&
|
||||
'code' in error &&
|
||||
(error as NodeJS.ErrnoException).code === 'ENOSPC'
|
||||
) {
|
||||
this.conversationFile = null;
|
||||
debugLogger.warn(ENOSPC_WARNING_MESSAGE);
|
||||
return; // Don't throw - allow the CLI to continue
|
||||
}
|
||||
debugLogger.error('Error initializing chat recording service:', error);
|
||||
throw error;
|
||||
}
|
||||
@@ -425,6 +443,16 @@ export class ChatRecordingService {
|
||||
fs.writeFileSync(this.conversationFile, newContent);
|
||||
}
|
||||
} catch (error) {
|
||||
// Handle disk full (ENOSPC) gracefully - disable recording but allow conversation to continue
|
||||
if (
|
||||
error instanceof Error &&
|
||||
'code' in error &&
|
||||
(error as NodeJS.ErrnoException).code === 'ENOSPC'
|
||||
) {
|
||||
this.conversationFile = null;
|
||||
debugLogger.warn(ENOSPC_WARNING_MESSAGE);
|
||||
return; // Don't throw - allow the conversation to continue
|
||||
}
|
||||
debugLogger.error('Error writing conversation file.', error);
|
||||
throw error;
|
||||
}
|
||||
@@ -474,7 +502,7 @@ export class ChatRecordingService {
|
||||
|
||||
/**
|
||||
* Gets the path to the current conversation file.
|
||||
* Returns null if the service hasn't been initialized yet.
|
||||
* Returns null if the service hasn't been initialized yet or recording is disabled.
|
||||
*/
|
||||
getConversationFilePath(): string | null {
|
||||
return this.conversationFile;
|
||||
|
||||
Reference in New Issue
Block a user