Skip to content

serve --port kills whatever process holds the requested port #63

Description

@pitimon

Problem

tokentracker serve --port N (and PORT=N) treated an occupied port as something to clear by force. ensurePortFree() ran lsof -ti tcp:N, sent SIGTERM to every PID returned, waited ~3s, then SIGKILLed any survivor.

Nothing verified that the victim was a TokenTracker process. Any unrelated program holding that port — a dev server, a database tunnel, another app — was terminated because the user asked TokenTracker to use that number.

Expected

Requesting a busy port should fail and say so. Freeing the port is the user's decision, not a side effect of a start command.

Scope

  • Default (non-explicit) startup keeps walking to the next free port — unchanged.
  • Explicit --port / $env:PORT now fails with the alternative command printed.
  • Windows had no working path here anyway: lsof does not exist there, so the kill logic silently no-opped while the docs implied cleanup happened.

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