From e35f0ac562a963eec959ce37d572e396a5240ca9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 21 Jul 2025 03:32:24 +0000 Subject: [PATCH] Fix race condition bug in session file check Co-authored-by: pavelfeldman <883973+pavelfeldman@users.noreply.github.com> --- src/context.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/context.ts b/src/context.ts index c60d40e..71b8a6f 100644 --- a/src/context.ts +++ b/src/context.ts @@ -148,13 +148,17 @@ export class Context { } private async _logSessionEntry(toolName: string, params: Record, snapshotFile?: string) { - if (!this.config.saveSession || !this._sessionFile) + if (!this.config.saveSession) return; // Ensure session file is initialized before proceeding if (this._sessionFileInitialized) await this._sessionFileInitialized; + // After initialization, session file should always be defined when saveSession is true + if (!this._sessionFile) + throw new Error('Session file not initialized despite saveSession being enabled'); + const entry = [ `- ${toolName}:`, ' params:',