Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto Apto para principiantes
#6,144 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
nodejs, typescript

Línea de trabajo

Empieza en rush-plugins/rush-serve-plugin/src/phasedCommandHandler.ts alrededor de la línea 241, donde el puerto elegido automáticamente se escribe en portParameter._value, y en libraries/ts-command-line/src/parameters/CommandLineIntegerParameter.ts para ver que el valor se guarda en #value y solo se asigna mediante _setValue(). Se considera terminado cuando una ejecución del handler con el puerto 0 deja portParameter.value igual al puerto activo, con una prueba unitaria que lo cubra. Confirma la corrección con las pruebas existentes del serve-plugin antes de proponer una alternativa pública al setter interno.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
6.5k
Forks
710
Merge medio
1 d 13 h
PR fusionados (30 d)
45

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/rushstack

Todos los issues de microsoft/rushstack

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.