Skip to content

preview: server scan starts at the saved session port and probes up to 100 unrelated ports despite an explicit --port #6204

Closed

Description

@lhagenmayer

Summary

readPreviewLifecycleState starts the server scan at the saved session port (saved?.port ?? startPort, packages/cli/src/commands/previewLifecycle.ts), and scanActiveServers probes MAX_PORT_SCAN (100) consecutive ports with GET /__hyperframes_config. If the saved session came from a different port range than the one requested now, the CLI probes up to 100 unrelated local ports before honoring the explicit --port; a start that ends up on another port can add a second scan window.

Reproduction (observed on 0.8.97; same logic on main / v0.8.191)

  1. hyperframes preview <project> --port 3021, then stop it (the session state keeps 3021).
  2. hyperframes preview <project> --port 32521.
  3. The CLI sends GET /__hyperframes_config to 3021–3120 (other local services) before using 32521.

Why it matters

Hosts that embed the CLI may only be allowed to touch a defined port range; probing unrelated ports reaches other local services.

Suggestion

When --port is given explicitly, scan only the requested window (or check only the saved port itself), or make the scan window configurable / allow disabling the scan.

Activity

  1. jrusso1020 commented on Oct 24, 2026

    @jrusso1020
    Collaborator

    Thanks for the clear repro, confirmed on main. readPreviewLifecycleState starts the scan at the saved session port (packages/cli/src/commands/previewLifecycle.ts:482). scanActiveServers then probes 100 consecutive ports from there (packages/cli/src/server/portUtils.ts:23 and :306). An explicit --port outside that window is only checked afterwards (previewLifecycle.ts:518), so it adds a probe on top of the scan rather than replacing it. Narrowing the scan when --port is given makes sense. — Rames

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions