-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
watch: fix watch args not being properly filtered #57936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
watch: fix watch args not being properly filtered #57936
Conversation
@@ -791,4 +791,54 @@ process.on('message', (message) => { | |||
`Completed running ${inspect(file)}`, | |||
]); | |||
}); | |||
|
|||
it('when multiple `--watch` flags are provided should run as if only one was', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: maybe node should error if multiple --watch
flags are provided?
I did not go with such a solution because that would be a breaking change, just ignoring extra --watch
flags is a non breaking change and it solves the issue at hand
If someone believes that multiple --watch
flags should cause an error I would propose to first land this change right now as a patch then as a followup I can also add the stricter validation which will be included as a breaking change in the next major 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And/or maybe, the erroring when multiple --watch
flags are provided is part of the bigger issues of node being quite permissive with its cli flags: #57864 and could be addressed as part of that 🤔
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #57936 +/- ##
==========================================
- Coverage 92.26% 90.27% -1.99%
==========================================
Files 325 630 +305
Lines 126673 186112 +59439
Branches 20783 36470 +15687
==========================================
+ Hits 116869 168017 +51148
- Misses 9576 10976 +1400
- Partials 228 7119 +6891 🚀 New features to boost your workflow:
|
cdc049a
to
4fa1ec0
Compare
currently when --watch is used, the argv arguments that the target script receives are filtered so that they don't include watch related arguments, however the current filtering logic is incorrect and it causes some watch values to incorrectly pass the filtering, the changes here address such issue
4fa1ec0
to
685fb31
Compare
Currently the logic for filtering out watch related flags before passing them to the watch target script is flawed, as it includes any flag (starting with
-
) that follows a flag starting with--watch
(code), this allows some watch flags to make it pass the filtering resulting in the generation of multiple watch processes which is both wasteful and can cause duplicate terminal logs (alongside other issues if the target script is side-effectful).For example if I run
the current implementation will spawn a process equivalent to:
which will then finally spawn the correct:
Here I'm addressing the incorrect filtering so that all the watch flags are correctly filtered out (making the extra process spawning disappear)
Fixes #57124