Skip to content

[rush-serve-plugin] Forward the auto-picked port to the port parameter - #6162

Open
Wei-Lun Li (b84330808) wants to merge 1 commit into
microsoft:mainfrom
b84330808:fix-rush-serve-plugin-port
Open

Wei-Lun Li (b84330808) wants to merge 1 commit into
microsoft:mainfrom
b84330808:fix-rush-serve-plugin-port

Conversation

@b84330808

Copy link
Copy Markdown

Summary

Fixes #6144

When rush start runs without an explicit port, rush-serve-plugin listens on an OS-assigned port and then writes it back into the portParameterLongName parameter, so the operations that receive that parameter get the real port. That stopped working after ts-command-line moved parameter values into native private fields (#5943): the plugin still assigns _value, which now just adds an unused property, so the parameter stays undefined and the port is never forwarded.

Details

The plugin now sets the value through the parameter's _setValue() method instead of assigning the backing field. _setValue() exists on older ts-command-line versions too, so this works regardless of how the parameter stores its value. It also stores a number, which is what an integer parameter expects; the generated command line is the same as before. An explicitly passed --port behaves as before.

It still goes through an internal method, like the old code did. A public way for plugins to override a parsed value would remove the cast, but that seemed out of scope for this fix.

How it was tested

Added a unit test that runs the handler with --port defined but not passed, then checks that the parameter ends up holding the port the server is listening on and that appendToArgList() forwards it. The test fails without the fix.

I used Claude Code to write this change.

When no port is given, the serve plugin listens on an OS-assigned port and
then writes that port back into the port parameter so that operations
receive it. It did this by assigning `_value`, but ts-command-line now keeps
parameter values in a native private field, so the assignment had no effect
and the parameter stayed undefined. Set the value through `_setValue()`
instead.

Fixes microsoft#6144

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@b84330808

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

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

1 participant