Skip to content

fix: use listen(0) for OS auto-port-allocation instead of getPort#1855

Open
inkpark wants to merge 3 commits intomicrosoft:mainfrom
inkpark:fix/issue-1854
Open

fix: use listen(0) for OS auto-port-allocation instead of getPort#1855
inkpark wants to merge 3 commits intomicrosoft:mainfrom
inkpark:fix/issue-1854

Conversation

@inkpark
Copy link
Copy Markdown

@inkpark inkpark commented Apr 12, 2026

fix: use listen(0) for OS auto-port-allocation instead of getPort pre-selection

In WSL/Windows port environments, the two-step pattern of reserving a
port with getPort() then rebinding to it caused massive EADDRINUSE
failures (~96 out of 100 attempts). Replacing with
server.listen(0)
lets the OS auto-assign a free port in a single step, achieving 0
failures in the same environment.
Fixes #1854

…-selection

In WSL/Windows port environments, the two-step pattern of
reserving a
      port with getPort() then rebinding to it caused massive EADDRINUSE
      failures (~96 out of 100 attempts). Replacing with
server.listen(0)
      lets the OS auto-assign a free port in a single step, achieving 0
      failures in the same environment.

      Fixes microsoft#1854
@inkpark
Copy link
Copy Markdown
Author

inkpark commented Apr 12, 2026

@inkpark please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.@inkpark 请阅读以下的Contributor License Agreement(贡献者许可协议)。如果你同意CLA,请回复以下信息。

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (默认 - 未指定公司) 我对我的提交内容拥有 sole 知识产权,并且我不是在为雇主工作的过程中进行提交。
@microsoft-github-policy-service agree
  • (当公司 given 时)我在为雇主工作期间进行提交(或者根据合同或适用法律,我的雇主对我的提交内容拥有知识产权)。我已获得雇主的许可,可以代表我的雇主进行 Submissions(提交内容) 并签订本协议。通过在下方签名,定义的术语“ You”包括我和我的雇主。
@microsoft-github-policy-service agree company="Microsoft"

贡献者许可协议 Contributor(贡献者)

@inkpark please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.@inkpark 请阅读以下的Contributor License Agreement(贡献者许可协议)。如果你同意CLA,请回复以下信息。

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (默认 - 未指定公司) 我对我的提交内容拥有 sole 知识产权,并且我不是在为雇主工作的过程中进行提交。
@microsoft-github-policy-service agree
  • (当公司 given 时)我在为雇主工作期间进行提交(或者根据合同或适用法律,我的雇主对我的提交内容拥有知识产权)。我已获得雇主的许可,可以代表我的雇主进行 Submissions(提交内容) 并签订本协议。通过在下方签名,定义的术语“ You”包括我和我的雇主。
@microsoft-github-policy-service agree company="Microsoft"

贡献者许可协议 Contributor(贡献者)

@microsoft-github-policy-service agree

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

import getPort from 'get-port';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove get-port from dependencies then?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the unused get-port dependency from package.json and package-lock.json, and cleaned up the corresponding entry in ThirdPartyNotices.txt. There are no remaining get-port usages in the repo.

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.

When running Java unit tests via Test Runner for Java in WSL2, the UI stays stuck at: Resolving launch configuration...

2 participants