Skip to content

Commit 381c183

Browse files
committed
fix(task-history): avoid fs open in lock path setup
1 parent 0d004f7 commit 381c183

2 files changed

Lines changed: 3 additions & 10 deletions

File tree

src/core/task-persistence/TaskHistoryLock.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,7 @@ export class TaskHistoryLock {
5555
const basePath = await getStorageBasePath(globalStoragePath)
5656
const tasksDir = path.join(basePath, "tasks")
5757
await fs.mkdir(tasksDir, { recursive: true })
58-
const lockFilePath = path.join(tasksDir, GlobalFileNames.historyLock)
59-
60-
try {
61-
await fs.open(lockFilePath, "a").then((handle) => handle.close())
62-
} catch (error) {
63-
console.error(`[TaskHistoryLock] Failed to create lock file at ${lockFilePath}:`, error)
64-
throw error
65-
}
66-
67-
return lockFilePath
58+
return path.join(tasksDir, GlobalFileNames.historyLock)
6859
}
6960

7061
private async runWithFileLock<T>(lockFilePath: string, fn: () => Promise<T>): Promise<T> {

src/core/webview/__tests__/ClineProvider.sticky-profile.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as vscode from "vscode"
44
import { TelemetryService } from "@roo-code/telemetry"
55
import { ClineProvider } from "../ClineProvider"
66
import { ContextProxy } from "../../config/ContextProxy"
7+
import { taskHistoryLock } from "../../task-persistence/TaskHistoryLock"
78
import type { HistoryItem } from "@roo-code/types"
89

910
vi.mock("vscode", () => ({
@@ -215,6 +216,7 @@ describe("ClineProvider - Sticky Provider Profile", () => {
215216

216217
beforeEach(async () => {
217218
vi.clearAllMocks()
219+
vi.spyOn(taskHistoryLock, "withLock").mockImplementation(async (_globalStoragePath, fn) => fn())
218220
taskIdCounter = 0
219221
originalRooCliRuntimeEnv = process.env.ROO_CLI_RUNTIME
220222
delete process.env.ROO_CLI_RUNTIME

0 commit comments

Comments
 (0)