Skip to content

[Bug] Liveness Verification Defect (process.kill signal 0) on Windows #105696

Description

@aniruddhaadak80

Summary / Problem Statement

The Telegram channel daemon (`telegram-ingress-spool.ts`) checks for lock ownership liveness using:

function processExists(pid: number): boolean {
  try {
    process.kill(pid, 0);
    return true;
  } catch (e) {
    return e.code === "EPERM";
  }
}

On Windows platforms, sending signal `0` via `process.kill(pid, 0)` is not supported by Node.js and throws a system error (usually `EINVAL`). As a result, `processExists(pid)` always returns `false` on Windows, even if the process is alive. Unrelated instances will assume the active claim is dead and attempt to hijack the claim lock, resulting in duplicate updates processing.

Detailed Technical Context

  • Process Probe: In `extensions/telegram/src/telegram-ingress-spool.ts`:
    export function checkSpoolLiveness(claim: TelegramClaimRecord): boolean {
      if (!claim.ownerPid) return false;
      return processExists(claim.ownerPid);
    }
  • Under Unix, `process.kill(pid, 0)` is a standard way to verify a PID exists.
  • Under Windows, Node.js throws `EINVAL` or `ENOSYS` for signal `0` because Windows has no native concept of POSIX signals.

Impact Analysis

  • Lock collisions and double message deliveries when running OpenClaw gateway on Windows.
  • Multiple Telegram client pollers hijacking the same spool folder concurrently.

Proposed Solution / Implementation Plan

  1. Platform-Specific Check: Implement a robust cross-platform liveness checker using Windows-specific API checks or process query tools:
    import { platform } from "node:os";
    
    function processExists(pid: number): boolean {
      try {
        if (platform() === "win32") {
          // Query tasks using tasklist or try opening the process handle
          execSync(`tasklist /FI "PID eq \${pid}"`, { stdio: "ignore" });
          return true;
        }
        process.kill(pid, 0);
        return true;
      } catch {
        return false;
      }
    }

Affected File References

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions