Skip to content

Test stop force-kill and cross-restart paths, including the pid-reuse guard #299

Closed

Description

@TMHSDigital

Summary

The force-kill path after a failed graceful quit, the cross-restart stop branch, and isRecorderProcess are untested.

Where

  • src/utils/lifecycle.ts:101-103, 335-336, 342-358
  • src/utils/sessions.ts:232-241 (isRecorderProcess)

Impact

Covers ffmpeg ignoring "q", stops from another server instance (#182), and the guard against killing an unrelated process that reused a pid. A regression could kill an arbitrary user process or report a stop that never happened.

Suggested fix

  • Fake child that never exits after "q" with gracefulMs: 50: killPid called, graceful: false
  • No attached child + live pid of a non-ffmpeg process (e.g. node -e "setInterval(()=>{},1e3)", processImage ffmpeg.exe): not killed, record still finalized
  • wgc record with live node.exe pid: stop file written, graceful: true on exit
  • Pid survives killPid (mock isAlive/killPid): throws "is still running"
  • Windows: isRecorderProcess(process.pid, "node.exe") true, "ffmpeg.exe" false

Acceptance criteria

  • Checklist cases covered
  • Lands with or before the pid-reuse fix (start-time check)

Getting started

  • Relevant files: src/utils/lifecycle.ts, src/utils/sessions.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: testing|src/utils/lifecycle.ts|stopSession

Activity

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

    @TMHSDigital
    OwnerAuthor

    Fixed in 6dd716c. src/__tests__/lifecycleStop.test.ts covers every case on the checklist:

    • a child that ignores "q" is killed, with graceful: false
    • a non-recorder pid left over from before a restart is never killed, and the record is still finalized
    • a wgc stop through the stop file is graceful, with no kill
    • a pid that survives the kill throws "is still running", both with an attached child and after a restart
    • on Windows, the real isRecorderProcess(process.pid, …) returns true for node.exe and false for ffmpeg.exe

    The pid-reuse start-time check (#284) is already in isOwnRecorder, and sessions.test.ts covers it.

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

    priority: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions