Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta Para iniciantes
#6,144 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
nodejs, typescript
Domínio
build-system, tooling

Direção de pesquisa

Comece em rush-plugins/rush-serve-plugin/src/phasedCommandHandler.ts, por volta da linha 241, onde a porta escolhida automaticamente é gravada em portParameter._value, e em libraries/ts-command-line/src/parameters/CommandLineIntegerParameter.ts para ver que o valor é mantido em #value e definido somente por meio de _setValue(). Está concluído quando uma execução do handler com a porta 0 deixa portParameter.value igual à porta ativa, com um teste unitário cobrindo isso. Confirme a correção com os testes existentes do serve-plugin antes de propor uma alternativa pública ao setter interno.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
6.5k
Forks
710
Merge médio
1d 16h
PRs com merge (30d)
40

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

  • Sem Dockerfile nem arquivo Docker Compose
  • Tem um modelo de pull request
  • Sem guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de microsoft/rushstack

Todas as issues de microsoft/rushstack

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.