Repository navigation
[rush-serve-plugin] Forward the auto-picked port to the port parameter - #6162
Open
Wei-Lun Li (b84330808) wants to merge 1 commit into
Open
Wei-Lun Li (b84330808) wants to merge 1 commit into
Wei-Lun Li (b84330808) wants to merge 1 commit into
Conversation
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>
Author
|
@microsoft-github-policy-service agree |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6144
When
rush startruns without an explicit port, rush-serve-plugin listens on an OS-assigned port and then writes it back into theportParameterLongNameparameter, 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 staysundefinedand 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--portbehaves 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
--portdefined but not passed, then checks that the parameter ends up holding the port the server is listening on and thatappendToArgList()forwards it. The test fails without the fix.I used Claude Code to write this change.