Skip to content

@std/net: Add isPortAvailable, etc. #7196

Open

Description

@yuhr

Is your feature request related to a problem? Please describe.

Currently, features of @std/net is very limited; only 1 API i.e. getAvailablePort.

Describe the solution you'd like

Provide some useful stuff as seen in https://deno.land/x/port@1.0.0.

Describe alternatives you've considered

Using https://deno.land/x/port@1.0.0/mod.ts

Activity

  1. Xavrir commented on Jun 30, 2026

    @Xavrir

    Happy to take this one. To start small, I'd add a single function alongside getAvailablePort:

    function isPortAvailable(port: number, options?: { hostname?: string }): boolean

    It returns true if the TCP port can be listened on, false on Deno.errors.AddrInUse, and rethrows anything else. hostname defaults to 0.0.0.0. I put it in unstable_is_port_available.ts (the @std/net/unstable-is-port-available export), and the JSDoc is upfront that the result is racy, so it points people at port: 0 / getAvailablePort for cases where they own the listener.

    It's already written, with tests for the available, in-use, hostname, and non-AddrInUse error cases, and it passes deno task lint, deno fmt --check, and deno test. Can open the PR whenever.

    Does that shape look right to you? I can fold in getAvailablePorts(count, options?) too if that's useful, or keep this one small.

  2. added a commit that references this issue on Aug 7, 2026
    e328681
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