memory: clean up active lock files on exit and termination signals

Abierto
#5,485 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Faris-as ya está trabajando en esto.

Desde el 6/11/2026.

  • #1 de @Faris-as — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
docker, node.js, typescript
Área
backend, devops

Línea de trabajo

Read src/memory/index.ts, the lock handling in file-lock.test.ts, and src/memory/Dockerfile; compare signal handling with src/everything/transports/stdio.ts and src/everything/Dockerfile. Check the linked prototype branch for existing work. Done means active locks owned by this process are cleaned up on shutdown, locks owned by others are preserved, the Docker stop signal is configured, and the memory tests pass.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Which server?

memory (@modelcontextprotocol/server-memory)

Server version

2.1.0

How did you run the server?

From a clone of this repository

Transport

stdio

Protocol era

Modern (2026-07-28)

MCP client and version

Claude Desktop / Autonomous Agent Orchestrator

Operating system and runtime

Linux / Node.js v24+

Server configuration
{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"]
    }
  }
}
Steps to reproduce
  1. Run @modelcontextprotocol/server-memory.
  2. Dispatch a mutation tool call (e.g. create_entities or add_observations) that acquires the lock via withFileLock.
  3. Terminate or stop the server process via SIGINT, SIGTERM, client disconnect, or container stop during the operation.
  4. Inspect the directory holding memory.jsonl.
  5. Attempt a subsequent write from another agent or container sharing the same graph file.
Expected behavior

The server should register signal handlers (SIGINT, SIGTERM) and exit cleanup hooks to remove any active lock file it currently holds, preventing orphaned lock files on abrupt shutdown.

Actual behavior

In Node.js, asynchronous finally blocks in withFileLock do not run when terminated by signals. Because src/memory registers no signal handlers (unlike src/everything/transports/stdio.ts), memory.jsonl.lock remains stranded on disk.
In multi-container or Docker environments where hostname !== os.hostname(), isLockOwnerDead returns false, forcing other agents to stall for up to 30–60 seconds before breaking the stale lock.
Additionally, in src/memory/Dockerfile, Node runs as PID 1 without STOPSIGNAL SIGINT, causing PID 1 to ignore SIGINT by default.

Already prototyped a fix?

Prompt for maintainer workflow:

"In src/memory/index.ts, track active lock files held by this process in an activeLocks map. On process exit and on SIGINT/SIGTERM, synchronously check if the lock file still contains our token, and if so, unlink it to avoid leaving stranded locks on abrupt shutdown. Add STOPSIGNAL SIGINT to src/memory/Dockerfile matching src/everything/Dockerfile. Add unit tests in file-lock.test.ts verifying active lock tracking and that cleanup leaves locks owned by another process intact."

Verification:

Before you submit
  • I searched existing issues and this is not a duplicate.
  • This is not a security vulnerability report.
Lenguaje dominante
TypeScript
Estrellas
91.7k
Forks
11.9k
Merge medio
3 h 30 min
PR fusionados (30 d)
199

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modelcontextprotocol/servers

Todos los issues de modelcontextprotocol/servers

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.