Skip to content

gate-lease keys its lock on TMPDIR, so two gates with different TMPDIRs run concurrently #2624

Closed

Description

@cliffhall

Problem

scripts/gate-lease.mjs places the machine-wide lock at path.join(env.XDG_RUNTIME_DIR || tmpdir(), "mcp-inspector-gate-lease"). os.tmpdir() follows $TMPDIR, so a gate started with a different TMPDIR takes a different lock and runs alongside a gate that is already holding one — exactly the overlap #2339 exists to prevent.

This is not hypothetical: the documented workaround for #2609 was TMPDIR=/tmp npm run local:gate. On 2026-10-07 one gate ran that way (release prep, #2622) while a second ran under the default macOS TMPDIR (#2609). Neither waited. The second went red at smoke:web:chromium on port 6298 in use (held by the first gate's launcher), and the first went red at smoke:web:firefox with a launch timeout / RenderCompositorSWGL GFX crash under the doubled load. Neither diff could have caused either failure.

Reproduce

# worktree A
TMPDIR=/tmp npm run local:gate
# worktree B, while A runs
npm run local:gate      # starts immediately instead of queueing

Expected

Any two local:gate runs on the same machine (same user) share one lease regardless of TMPDIR.

Suggested fix

Key the lock on something TMPDIR does not move — e.g. a fixed per-user path (os.homedir()-based, or /tmp/mcp-inspector-gate-lease-<uid> on POSIX), keeping XDG_RUNTIME_DIR if that is still wanted. The header comment's "machine-wide" claim should match whatever is chosen.

Priority

Medium (rubric total 7):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugv2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions