[rush-serve-plugin] The auto-picked port never reaches the port parameter: `_value` is ignored since ts-command-line uses `#value`
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 72/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- nodejs, typescript
- 領域
- build-system, tooling
研究方向
從 rush-plugins/rush-serve-plugin/src/phasedCommandHandler.ts 第 241 行左右開始,那裡會把自動選取的連接埠寫入 portParameter._value;接著查看 libraries/ts-command-line/src/parameters/CommandLineIntegerParameter.ts,確認該值保存在 #value 中,且只能透過 _setValue() 設定。當連接埠為 0 的處理程式執行後,portParameter.value 等於啟用中的連接埠,並且有單元測試涵蓋這一點,即為完成。在提出替代內部 setter 的公開方案之前,先用現有的 serve-plugin 測試確認修復。
由索引模型根據 Issue 內容生成。
描述
Summary
When rush start (or another watch-mode phased command with portParameterLongName) runs without an explicit port, @rushstack/rush-serve-plugin listens on an OS-assigned port and then tries to publish it through the command-line parameter, so that other plugins (and the operations that receive the parameter) see the real port. It does so by writing portParameter._value. Since @rushstack/ts-command-line switched parameters to native private fields (#5943), CommandLineIntegerParameter stores its value in #value, so the assignment only adds an unused property. portParameter.value stays undefined, and nothing downstream sees the port.
Versions
@microsoft/rush/@rushstack/rush-serve-plugin5.181.0@rushstack/ts-command-line5.3.17 (any version that includes #5943)- Node.js 22
Repro
- Configure
rush-serve-pluginwithportParameterLongName: "--port", and define--portas anintegerparameter of thestartcommand, associated with a phase. - Add a second plugin that taps
createOperationsAsyncafter the serve plugin (any stage above -1) and logscontext.customParameters.get('--port').value. - Run
rush startwithout--port.
Expected
The serve plugin logs Content is being served from: https://localhost:<port>/, and the second plugin logs the same <port>.
Actual
The second plugin logs undefined. An explicit --port 4321 works, because then the value comes from the parser.
Code pointer (main)
rush-plugins/rush-serve-plugin/src/phasedCommandHandler.ts, line 241:(portParameter as unknown as { _value?: string })._value = `${activePort}`;libraries/ts-command-line/src/parameters/CommandLineIntegerParameter.ts: the value lives in#valueand is written only by_setValue().
Suggested fix
Set the value through the parameter's setter (it also stores a number, as the integer parameter expects, instead of a string):
(portParameter as unknown as { _setValue(data: unknown): void })._setValue(activePort);
Since _setValue is @internal, a public way for a plugin to override a parsed parameter value (or a session-level API that publishes the serve plugin's active port) would avoid the cast. A unit test that runs the handler with port 0 and checks portParameter.value would catch a regression.
Filed with help from GitHub Copilot (AI); reviewed by the reporter.
- 主要語言
- TypeScript
- 星號
- 6.5k
- 分支
- 710
- 平均合併
- 1 天 15 小時
- 30 天內合併 PR
- 37
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/rushstack 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
[rush] Upgrade the pnpm-sync-lib dependency to 0.3.5.可能已有人在做 @martinnaj 於 16 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
microsoft/rushstack#5971 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
microsoft/rushstack#5902 · 1 個 reaction ·
維護者通常 1 天內回覆
查看 microsoft/rushstack 的全部 Issue
相似的 Issue
-
`cf complete zsh >> .zshrc` fails on vanilla zsh可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
cloudflare/cf#340 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1 小時以內 新手友好度 75/100
StoDevX/AAO-React-Native#8785 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 75/100
-
bnv-manager-v2: accept_invite creates the Mailcow domain admin before the commit可能已有人在做 @myOmikron 今天認領。 未關閉bug ready-for-agent
難度 2/5 1-3 小時 新手友好度 82/100