Skip to content

[Bug]: store lock refuses restart with a recycled PID; short-link and write-concurrency gaps #469

Closed

Description

@jimhoyd

Runtime revision and environment

main at d939969 (static source review; not executed against a deployment). Node/OS/deployment: not applicable.

Minimal reproduction

Reported by review, not independently reproduced. All in packages/store/src/store.ts.

  • Stale lock with a recycled PID. lock() (lines 31-49) treats a lock file containing the current process's PID as live. A container restarted after an unclean exit usually runs as the same PID (often PID 1), so it refuses to start until the lock file is removed by hand. There is also a small window between open(path, 'wx') and writeFile in which another process reads an empty PID.
    • Fix: record a boot/instance identifier (or process start time) alongside the PID, treat a lock carrying our own PID but not our own instance id as stale, and write the lock atomically (write temp file, then link/rename).
  • Short-link destination may be missing. Short-link validation (lines 91-93) requires the destination field to be a string http-url, but not required. A record without a destination produces 302 Location: undefined (line 168) and still counts a click.
    • Fix: require the destination field at configuration time, and return 404 without incrementing when the value is absent.
  • HEAD counts clicks. dispatchShortLink increments on HEAD as well as GET (lines 165-167).
    • Fix: resolve without incrementing on HEAD.
  • No conditional writes. PUT/PATCH (lines 153-154) are last-write-wins with no ETag/If-Match.
    • Fix: return an ETag (record version) and honour If-Match with 412.
  • Idempotency keys are shared across callers, so two callers that choose the same key collide.
    • Fix: scope stored keys by principal (or client) when the mount is authenticated.

Activity

  1. added
    bug
    extension
    on Sep 22, 2026
  2. added 2 commits that reference this issue on Sep 22, 2026
    a3af3bb
    ab4ec96
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

    bugextension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions