Skip to content

fix(devframe): skip ports held on another loopback address - #461

Open
DBAAZzz wants to merge 1 commit into
devframes:mainfrom
DBAAZzz:fix/get-port-loopback-families
Open

DBAAZzz wants to merge 1 commit into
devframes:mainfrom
DBAAZzz:fix/get-port-loopback-families

Conversation

@DBAAZzz

@DBAAZzz DBAAZzz commented Oct 26, 2026

Copy link
Copy Markdown

fix #460

If another server holds 127.0.0.1:<port>, getPort from get-port-please still returns that port for localhost, because it tries to bind only one address. devframe then binds [::1]:<port>, and requests to 127.0.0.1:<port> go to the other server.

This PR patches get-port-please. devframe bundles it, so the patch ships with devframe. For a loopback or wildcard host, getPort now also tries 127.0.0.1, ::1, 0.0.0.0 and ::. If one of them fails with EADDRINUSE or EACCES, the port is in use. Other errors, like EADDRNOTAVAIL when IPv6 is off, mean that the address does not exist, so they are ignored.

The new test in dev.test.ts fails on main and passes with the patch, on Linux (IPv6 on) and on macOS. I will send the same change upstream for unjs/get-port-please#121. You can remove the patch after upstream releases it.

@vercel

vercel Bot commented Oct 26, 2026

Copy link
Copy Markdown

@DBAAZzz is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

👁️‍🗨️ Review this pull request with grouped, summarized diffs at:
👉 https://pulls.review/gh/devframes/devframe/461?from=github-actions[bot]

raw result

💭 analyzed by vercel-ai-gateway/anthropic/claude-sonnet-5
🕰️ 2026-10-26 03:12 UTC
🔗 head ed51416
🤖 automated by pulls.review

{
  "headSha": "ed514166f3a54cb8da1a8d564038631105bb558e",
  "result": {
    "overallSummary": "Fixes #460 where devframe could bind a port already held on another loopback address, by patching the bundled get-port-please to check all loopback/wildcard addresses before considering a port free, plus a regression test and the resulting lockfile change.",
    "groups": [
      {
        "key": "port-patch",
        "label": "get-port-please loopback patch",
        "summary": "Patches the bundled get-port-please dependency so that for a loopback or wildcard host, getPort also probes 127.0.0.1, ::1, 0.0.0.0 and :: before declaring a port free, avoiding devframe binding a port already held by another process on a different loopback address. Wires the patch into pnpm via patchedDependencies.",
        "category": "core",
        "filePaths": [
          "patches/get-port-please@3.2.0.patch",
          "pnpm-workspace.yaml"
        ],
        "critical": true,
        "fileNotes": [
          {
            "path": "patches/get-port-please@3.2.0.patch",
            "text": "Only EADDRINUSE/EACCES on a loopback address count as in use; other errors (e.g. EADDRNOTAVAIL when IPv6 is disabled) are treated as the address not existing and ignored."
          }
        ]
      },
      {
        "key": "tests",
        "label": "Regression test",
        "summary": "Adds a test that reproduces the bug (a port bound on 127.0.0.1 by another server) and verifies createDevServer no longer picks that port.",
        "category": "tests",
        "filePaths": [
          "packages/devframe/src/adapters/__tests__/dev.test.ts"
        ]
      },
      {
        "key": "lockfile",
        "label": "Lockfile update",
        "summary": "Generated lockfile update reflecting the new patched dependency entry.",
        "category": "deps",
        "filePaths": [
          "pnpm-lock.yaml"
        ]
      }
    ],
    "schemaVersion": 1,
    "source": "llm",
    "generatedAt": "2026-10-26T03:12:49.139Z",
    "model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
    "locale": "en"
  }
}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

createDevServer starts on a port that another server holds on 127.0.0.1

1 participant