Skip to content

pickPrimaryPort

pickPrimaryPort(ports, httpProbe?): Promise<number | null>

Defined in: src/preview.ts:348

Pick the primary dev-server port from a set of listening ports, using this rule:

  1. If any port from the curated list is present, return the one that appears FIRST in CURATED_PORTS (list-order priority, NOT numeric). No HTTP probe for curated ports.
  2. Otherwise, among non-curated ports, return the numerically LOWEST that passes the HTTP liveness probe.
  3. If nothing answers → null.

number[]

Listening ports detected in the worktree (any order).

(port) => Promise<boolean>

Injectable probe; defaults to real network call.

Promise<number | null>