Bug Description
On gateway restart, memos-local-plugin fails to acquire its runtime lock during the brief window between SIGTERM and process death, causing DuplicateOpenClawRuntimeError to abort register(). All hooks and tools become unavailable until next restart.
Reproduction
- Gateway running with plugin loaded
- Run
systemctl --user restart openclaw-gateway or openclaw gateway restart
- Check logs:
[plugins] memos-local-plugin failed during register: DuplicateOpenClawRuntimeError: memos-local OpenClaw runtime is already active (pid=XXXX)
memos_search / memos_get tools unavailable, before_prompt_build hook not triggered
Root Cause
In runtime-lock.js, acquireOpenClawRuntimeLock() loop:
if (owner && pidIsAlive(owner.pid)) {
throw new DuplicateOpenClawRuntimeError(lockDir, owner); // BLOCKS here
}
// Only clears lock when !owner (owner is null)
if (!owner && !lockLooksStale(lockDir, now(), unwrittenOwnerStaleMs)) {
throw new DuplicateOpenClawRuntimeError(lockDir, null);
}
fs.rmSync(lockDir, { recursive: true, force: true });
After SIGTERM, pidIsAlive(old_pid) returns true during the 100-500ms grace period before OS reclaims the PID. The lock-clear path only handles !owner, so it never triggers when owner exists and pid is alive.
Proposed Fix
Add retry with backoff when owner pid is alive:
if (owner && pidIsAlive(owner.pid)) {
await new Promise(r => setTimeout(r, 200));
continue; // retry
}
Environment
- OpenClaw: 2026.7.1-2
- memos-local-plugin: 2.0.16 (npm) / 2.0.0-beta.5 (registered)
- Node.js: 24.18.0
- OS: Linux 7.0.14-6-pve (Proxmox)
Bug Description
On gateway restart,
memos-local-pluginfails to acquire its runtime lock during the brief window between SIGTERM and process death, causingDuplicateOpenClawRuntimeErrorto abortregister(). All hooks and tools become unavailable until next restart.Reproduction
systemctl --user restart openclaw-gatewayoropenclaw gateway restartmemos_search/memos_gettools unavailable,before_prompt_buildhook not triggeredRoot Cause
In
runtime-lock.js,acquireOpenClawRuntimeLock()loop:After SIGTERM,
pidIsAlive(old_pid)returnstrueduring the 100-500ms grace period before OS reclaims the PID. The lock-clear path only handles!owner, so it never triggers when owner exists and pid is alive.Proposed Fix
Add retry with backoff when owner pid is alive:
Environment