[rush-serve-plugin] The auto-picked port never reaches the port parameter: `_value` is ignored since ts-command-line uses `#value`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- nodejs, typescript
- Ambito
- build-system, tooling
Direzione di ricerca
Inizia da rush-plugins/rush-serve-plugin/src/phasedCommandHandler.ts intorno alla riga 241, dove la porta scelta automaticamente viene scritta in portParameter._value, e da libraries/ts-command-line/src/parameters/CommandLineIntegerParameter.ts per vedere che il valore è mantenuto in #value e impostato solo tramite _setValue(). Il lavoro è completo quando un'esecuzione dell'handler con porta 0 lascia portParameter.value uguale alla porta attiva, con un test unitario che lo copra. Conferma la correzione con i test esistenti del serve-plugin prima di proporre un'alternativa pubblica al setter interno.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 6.5k
- Fork
- 710
- Merge medio
- 1g 16h
- PR unite (30g)
- 40
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/rushstack
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[rush] Upgrade the pnpm-sync-lib dependency to 0.3.5.Forse già presa @martinnaj l’ha presa 16 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
microsoft/rushstack#5971 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
microsoft/rushstack#5902 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/rushstack
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
apache/rocketmq-dashboard#6872 ·
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
fab-geocommuns/RNB-site#539 ·
I maintainer di solito rispondono entro 2 giorni
-
Guest multiview tile label leaks raw virtual-source-id "Whip" instead of the guest name / slot labelAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Eyevinn/open-live-studio#211 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue
Difficoltà 2/5 Mezza giornata Idoneità per principianti 72/100
sujithputta02/Esapay#13 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
ehmpathy/rhachet-roles-bhuild#468 ·
I maintainer di solito rispondono entro 1 giorno