Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[rush-serve-plugin] The auto-picked port never reaches the port parameter: `_value` is ignored since ts-command-line uses `#value`

Aperta Adatta ai principianti
#6,144 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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

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-plugin 5.181.0
  • @rushstack/ts-command-line 5.3.17 (any version that includes #5943)
  • Node.js 22

Repro

  1. Configure rush-serve-plugin with portParameterLongName: "--port", and define --port as an integer parameter of the start command, associated with a phase.
  2. Add a second plugin that taps createOperationsAsync after the serve plugin (any stage above -1) and logs context.customParameters.get('--port').value.
  3. Run rush start without --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 #value and 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

Apri in Codespaces

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/rushstack

Tutte le issue di microsoft/rushstack

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.