Skip to content

Unbind cleanup can orphan runtime-rotation-app-helper-owner.<pid>.json permanently #666

Description

@possibilities

Follow-up from CodeRabbit review of #665, filed rather than folded in because the code belongs to #664 (approved, awaiting merge) and #665 is deliberately one behavior change.

Owner files can be orphaned forever

Two branches in lib/runtime/app-bind.ts remove a helper status file without checking helperOwnershipMatches:

  • lib/runtime/app-bind.ts:1560-1563 — dead PID in a running record
  • lib/runtime/app-bind.ts:1592-1597 — any non-running record

Both then gate removeHelperOwner on helperOwnershipMatches. When the status token and the owner token disagree, unbind deletes the status file and keeps runtime-rotation-app-helper-owner.<pid>.json. The next unbind iterates status paths only, so nothing ever rediscovers that owner file. It accumulates under the multi-auth root indefinitely.

Two coherent policies; the codebase should pick one deliberately:

  1. Conservative — treat a mismatched record as not ours, preserve both files, warn.
  2. Decisive — treat the PID as dead and remove both.

Suggested regression coverage in test/app-bind.test.ts: mismatched-token non-running record (both files preserved), dead-PID running record (both files removed), and readdir failing with a non-ENOENT code (warning emitted, legacy path still checked).

Helper unlinks are not retried on Windows

helperCleanupPaths feeds a best-effort unlinkIfExists loop that swallows every error. On Windows, a status file for a helper killed milliseconds earlier can still fail with EBUSY/EPERM, and the record survives unbind. The readdir above it (lib/runtime/app-bind.ts:1512) and the rm below it (:1662) both use withFileOperationRetry; the unlink loop is the remaining gap.

Credit: CodeRabbit, on #665.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions