Skip to content

fix(web): avoid browser-blocked ports when starting the Web Host #694

Closed

Description

@outlier27-cell

Problem

At origin/main 3cb2ecf, WebHost.start accepts every TCP port and defaults to OS allocation. A server can successfully bind port 6000, but browser/Node Fetch refuses the URL before any HTTP request. The full Windows suite actually failed in tests/web/web-host.test.ts with TypeError: fetch failed / cause: bad port after automatic allocation.

Reproduction and evidence

An isolated Node HTTP server listening on 127.0.0.1:6000 starts successfully; fetch(http://127.0.0.1:6000) rejects with cause bad port. No model, user Session, or installed Pi runtime was involved. Current WebHost.start directly listens, accepts its address, and publishes web_host_started without checking the port. Explicit CLI --port 6000 has the same problem.

The WHATWG Fetch port-blocking contract specifies these ports: https://fetch.spec.whatwg.org/#port-blocking . This is an HTTP/browser contract rather than a provider compatibility change.

Proposed acceptance

Reject an explicitly requested blocked port with a clear diagnostic. When port 0 requests OS allocation, close and retry blocked allocations within a bounded limit; publish readiness only after a usable port is retained. Preserve loopback binding, token authentication, occupied-port errors and cleanup. Add deterministic retry/exhaustion tests and run check/test.

Deduplication and claim

Searched all-state Issues for bad port and all-state PRs for blocked port / unsafe port. No equivalent Web Host fix found. I am implementing this on independent branch fix/web-browser-safe-port based on latest origin/main.

Activity

  1. outlier27-cell commented on Oct 7, 2026

    @outlier27-cell
    ContributorAuthor

    Implementation published on independent branch fix/web-browser-safe-port, source commit 321fcf7. Five transport regressions and bun run check pass; full local Windows bun run test ran with 2181 pass / 12 fail / 14 skip (renderer/footer assertions, symlink EPERM and worktree timeout; runner stops before UI). Exact-head CI will be checked and corrected on this branch. Reusable source/evidence record: https://github.com/outlier27-cell/openpi/blob/fix/web-browser-safe-port/docs/research/WEB_BROWSER_PORT_2026-10-07.md . No installed runtime/model acceptance claimed.

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