watch: add initial implementation for node --watch#44366
Conversation
|
Review requested:
|
node --watch
2d1f1cb to
e8323f0
Compare
e8323f0 to
65d5f5b
Compare
a64b5c8 to
cfad875
Compare
fd9c710 to
e73ee24
Compare
e73ee24 to
e8c2d61
Compare
e8c2d61 to
f497852
Compare
|
Oh, I see that the inspector tests are already moved to sequential in #44551, though unfortunately the flake is still here (e.g. https://ci.nodejs.org/job/node-test-commit-aix/42722/) |
|
@joyeecheung out of these 6 failed runs, and here: however, I do see some flakes that seem to be related to the overall system load (i.e it looks like the failures happen when the program is not restarted and it should be): watch mode does include parts that relay on both CPU (file change throttling) & disk loads, |
|
After landing this into the v16.x branch, this test fails: |
|
Watch mode seems wonderful but I need a way to say I really want to exit without a restart. Is there an API or an option on Exit? |
@BobFrankston can you kindly open an issue with an example describing your use case? |
|
Since the documentation is sparse, I conflated **nodemon'**s automatic restart with the restart on change. I realize --watch may not only do a restart on change but not assure the program continues to run after failure. Both are useful but distinct. If it only restarts on change, then it's worth thinking about a --persist or related option. |
|
Maybe it would be good to add the ability to handle multiple entry points? |
|
I am experiencing an issue where on some restarts, it seems watch mode restarts constantly for up to about 60 seconds - Eventually it recovers and runs normally. I'm running on Windows 11 x64, Node v19.8.1 (not quite latest). Process Explorer confirmed that it was rapidly restarting and making 100s (or 1000s) of new processes that were dying quickly. My app does not modify local files. I believe my editor is also not repeatedly editing files. I'm not even sure where/how to start debugging this... I should probably make a new issue.Uuntil I pull all the details into a real issue, this will have to suffice ;) @mule-stand Running @BobFrankston You can add an infinite sleep at the end of your own program to keep |
|
@cinderblock Please open an issue. This PR is not the right place to discuss such problems in depth. |
|
@cinderblock Did you open an issue for this restart thing? I am facing the same issue with Win 11 and Node 20. I try to reproduce this with a small code example, but it is kinda random and I don't know what causing the issue. Edit: |
| } | ||
|
|
||
| async function restart() { | ||
| process.stdout.write(`${clear}${green}Restarting ${kCommandStr}${white}\n`); |
There was a problem hiding this comment.
This "clear" should be at least configurable, as the --preserveWatchOutput option with tsc
| $ node --watch-path=./src --watch-path=./tests index.js | ||
| ``` | ||
|
|
||
| This option is only supported on macOS and Windows. |
There was a problem hiding this comment.
What part of this is disabled or partially functional on Linux? fs.watch() has caveats but certainly doesn't advertise as limited to Windows and macOS.
Is there an open issue for making this supported on Linux?
Fixes: #40429
This is currently still WIP, opening this PR to gather some initial feedback
TODO
making things configurable?