withPathLock (utils/pathMutex.ts)

gemini-cli · packages/core/src/utils/pathMutex.ts · typescript · Apache-2.0
infra

Provides an in-process per-path mutex to serialize file operations with optional abort.

// Source: https://github.com/google-gemini/gemini-cli | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * @license
 * Copyright 2026 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * In-process, per-path mutex used to serialize read-modify-write sequences
 * against the same file.
 *
 * Parallel tool execution (notably sub-agents) can schedule two writes to the
 * same path concurrently. Without serialization the two sequences interleave
 * and one update is silently lost.
 *
 * Scope: this coordinates callers inside a single process only. It does not
 * guard against a second Gemini CLI process, an editor, or any other program
 * writing the same file; that would 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key