Skip to content

Orphan reaping can force-kill an unrelated process tree that reused a recorder pid #284

Closed

Description

@TMHSDigital

Summary

Startup reaping and cross-restart stop identify the recorder only by image name (tasklist). #185 added a start-time check for the server-owner pid, but not for the recorder pid. For WGC sessions the expected image is node.exe, so any Node process that reuses the pid is killed with taskkill /T /F.

Where

  • src/utils/sessions.ts:219-221 (expectedImage returns node.exe for wgc)
  • src/utils/sessions.ts:232-241 (isRecorderProcess)
  • src/utils/sessions.ts:265-270 (killPid, /T /F)
  • src/utils/sessions.ts:718-722 (reapOrphans)
  • src/utils/lifecycle.ts:338-352 (runStop cross-restart branch)

Details

No recorder creation time is stored on SessionRecord. The WGC recorder exits on its own when its stdin closes (src/wgcRecorder.ts:187), so after a hard server death its pid is always free for reuse. A later node.exe with that pid (editor helpers, other MCP servers) passes the image check.

Impact

One server start after a crash during a WGC recording can kill an unrelated Node process and everything it spawned.

Steps to reproduce

  1. Start a wgc recording
  2. Kill the server hard (taskkill /F)
  3. Start Node processes until one gets the recorder's old pid
  4. Restart the server: reapOrphans kills that process tree

Suggested fix

Record the recorder's creation time at spawn (processInfo(child.pid)), store it on the record, and require a match within OWNER_START_SLACK_MS before killing, as isSameServer does. Drop /T when killing a stored pid.

Acceptance criteria

  • Recorder start time stored on the session record
  • Reap/stop refuse to kill a pid whose start time does not match
  • Test: a live non-recorder process with a matching image name is not killed

Related: #185

Getting started

  • Relevant files: src/utils/sessions.ts, src/utils/lifecycle.ts
  • How to run tests: npm run build && npm test (also npm run typecheck and npm run lint)
  • Related docs: CONTRIBUTING.md, AGENTS.md

Filed by repo-audit/full-audit at f2fda28. Severity: medium. Effort: S-M. audit-key: bug|src/utils/sessions.ts|isRecorderProcess

Activity

  1. added
    bug
    on Nov 9, 2026
  2. TMHSDigital commented on Nov 10, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 2b588ec: records now store pidSpawnedAt (start and resume), and isOwnRecorder requires the running process to match the image and not be newer than the spawn before reapOrphans or the cross-restart runStop kill it. The tree kill (/T) stays, since the real WGC recorder's ffmpeg children must go too; it now only runs on a verified recorder. Verified with pure isSameRecorder tests and a Windows test that a live node.exe started after the record's spawn time is not claimed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions