GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — watch: add initial implementation for `node --watch` by MoLow · Pull Request #44366 · nodejs/node

Conversation

@MoLow

@MoLow MoLow commented Aug 23, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Fixes: #40429

This is currently still WIP, opening this PR to gather some initial feedback

TODO

  • write documentation
  • add tests
  • explore use-cases and if they should be part of the initial implementation
    • error handling / crashing
    • debugging experience
    • making things configurable?
    • please comment if you come up with any interesting use case

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

shrujalshah28, RaisinTen, Mhdi-kr, gkiely, washingtonsoares, crutchcorn, benjamingr, songkeys, dawei-67, irena-postman, and 63 more reacted with thumbs up emoji bricss, kirillgroshkov, GaryGSC, MomenNano, CanRau, mburakerman, himynameisdave, styfle, codingjlu, laissonsilveira, and 20 more reacted with hooray emoji CanRau, bricss, himynameisdave, andrenarchy, codingjlu, laissonsilveira, Renan1fps, isarojdahal, soupaulosilva, pawelgrzybek, and 17 more reacted with heart emoji ErickWendel, tony-go, M4gie, akira28, reggi, shrujalshah28, RaisinTen, jtoar, theoludwig, Mhdi-kr, and 37 more reacted with rocket emoji josefaidt, avindra, ErickWendel, tony-go, M4gie, Jolg42, tonivj5, MomenNano, Mhdi-kr, washingtonsoares, and 13 more reacted with eyes emoji
All reactions
  • 👍 73 reactions
  • 🎉 30 reactions
  • ❤️ 27 reactions
  • 🚀 47 reactions
  • 👀 23 reactions
@nodejs-github-bot

nodejs-github-bot commented Aug 23, 2022

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/startup
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Aug 23, 2022
@MoLow MoLow changed the title watch: add initial implementation watch: add initial implementation for node --watch Aug 23, 2022
aduh95
aduh95 reviewed Aug 23, 2022
View reviewed changes
Comment thread lib/internal/main/watch_mode.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 reviewed Aug 23, 2022
View reviewed changes
Comment thread lib/internal/main/watch_mode.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MoLow
MoLow force-pushed the watch-mode-initial-implementation branch from 2d1f1cb to e8323f0 Compare August 24, 2022 12:41
benjamingr
benjamingr reviewed Aug 24, 2022
View reviewed changes
Comment thread lib/internal/main/watch_mode.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

tniessen
tniessen reviewed Aug 24, 2022
View reviewed changes
Comment thread lib/internal/main/watch_mode.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MoLow
MoLow force-pushed the watch-mode-initial-implementation branch from e8323f0 to 65d5f5b Compare August 25, 2022 12:24
benjamingr
benjamingr reviewed Aug 25, 2022
View reviewed changes
Comment thread lib/internal/main/watch_mode.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MoLow
MoLow force-pushed the watch-mode-initial-implementation branch 8 times, most recently from a64b5c8 to cfad875 Compare August 26, 2022 10:05
benjamingr
benjamingr reviewed Aug 26, 2022
View reviewed changes
Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

benjamingr
benjamingr reviewed Aug 26, 2022
View reviewed changes
Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

benjamingr
benjamingr reviewed Aug 26, 2022
View reviewed changes
Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MoLow
MoLow force-pushed the watch-mode-initial-implementation branch 2 times, most recently from fd9c710 to e73ee24 Compare August 28, 2022 09:25
@MoLow
MoLow marked this pull request as ready for review August 28, 2022 09:25
@MoLow
MoLow force-pushed the watch-mode-initial-implementation branch from e73ee24 to e8c2d61 Compare August 28, 2022 13:37
jasnell
jasnell reviewed Aug 28, 2022
View reviewed changes
Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MoLow
MoLow force-pushed the watch-mode-initial-implementation branch from e8c2d61 to f497852 Compare August 28, 2022 18:56
aduh95
aduh95 reviewed Aug 29, 2022
View reviewed changes
Comment thread lib/internal/main/watch_mode.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/main/watch_mode.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/modules/esm/loader.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/watch_mode/files_watcher.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/watch_mode/files_watcher.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung

joyeecheung commented Sep 12, 2022

Copy link
Copy Markdown
Member

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/)

MoLow reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MoLow

MoLow commented Sep 12, 2022

Copy link
Copy Markdown
Member Author

@joyeecheung out of these 6 failed runs,
some are real deterministic & not flaky failures,
e.g here:

 Expected values to be strictly equal:
17:41:37             + actual - expected
17:41:37             
17:41:37             + 'C:\\workspace\\node-test-binary-windows-js-suites\\node\\Release\\node.exe: bad option: --import\r\n'
17:41:37             - ''

and here:

Error [ERR_NO_CRYPTO]: Node.js is not compiled with OpenSSL crypto support

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):
https://ci.nodejs.org/job/node-test-commit-aix/42722/nodes=aix72-ppc64/console
https://ci.nodejs.org/job/node-test-commit-osx/47228/nodes=osx1015/console
https://ci.nodejs.org/job/node-test-binary-armv7l/2327/RUN_SUBSET=js,label=debian10-armv7l/console

watch mode does include parts that relay on both CPU (file change throttling) & disk loads,
so I will try moving to sequential

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MoLow MoLow mentioned this pull request Sep 12, 2022
test: move watch mode tests to sequential #44610
Closed
@RafaelGSS RafaelGSS mentioned this pull request Sep 13, 2022
2022-10-18, Version 19.0.0 (Current) #44626
Merged
@tniessen tniessen mentioned this pull request Sep 15, 2022
Investigate flaky test-watch-mode #44655
Closed
@RafaelGSS RafaelGSS mentioned this pull request Sep 26, 2022
v18.10.0 proposal #44799
Merged
This was referenced Sep 29, 2022
[v18.x backport] cli: add --watch #44814
Closed
[v18.x backport] cli: add --watch #44815
Closed
@juanarbol

juanarbol commented Oct 3, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

After landing this into the v16.x branch, this test fails: test/parallel/test-watch-mode.mjs; would you mind backporting this to the v16.x release branch?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@juanarbol juanarbol mentioned this pull request Oct 3, 2022
test: split watch mode inspector tests to sequential #44551
Merged
@MoLow MoLow mentioned this pull request Oct 3, 2022
[v16.x backport] watch mode #44877
Closed
@merceyz merceyz mentioned this pull request Oct 4, 2022
fix(pnp): report loaded modules in watch mode yarnpkg/berry#4934
Merged
3 tasks done
@danielleadams danielleadams mentioned this pull request Oct 11, 2022
v18.11.0 proposal #44968
Merged
@MoLow MoLow mentioned this pull request Oct 12, 2022
[v16.x backport] watch mode #44976
Closed
@richardlau richardlau mentioned this pull request Oct 27, 2022
test: use common/tmpdir in watch-mode ipc test #45211
Merged
@BobFrankston

BobFrankston commented Dec 4, 2022

Copy link
Copy Markdown

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@GeoffreyBooth GeoffreyBooth mentioned this pull request Dec 4, 2022
Move ESM loaders off-thread #44710
Merged
7 tasks done
@MoLow

MoLow commented Dec 4, 2022

Copy link
Copy Markdown
Member Author

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BobFrankston

BobFrankston commented Dec 4, 2022

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardlau richardlau mentioned this pull request Dec 8, 2022
v16.19.0 proposal #45791
Merged
@tniessen tniessen mentioned this pull request Dec 11, 2022
watch: add CLI flag to preserve output #45717
Merged
@mbelsky mbelsky mentioned this pull request Dec 13, 2022
Shell scripting recipes rauschma/nodejs-shell-scripting#17
Open
@mule-stand

mule-stand commented Apr 1, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Maybe it would be good to add the ability to handle multiple entry points?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cinderblock

cinderblock commented Apr 24, 2023

Copy link
Copy Markdown

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 node ... is by definition one entry point. What are you imagining would change? In any case, this discussion would probably be better in a new Feature Request issue.


@BobFrankston You can add an infinite sleep at the end of your own program to keep node alive and watching for changes. This is what nodemon does internally. You need some process still running to be notified of any changes to the file system. You might even check process.execArgv.includes('--watch') and only run the infinite sleep if watch mode is enabled.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tniessen

tniessen commented Apr 25, 2023

Copy link
Copy Markdown
Member

@cinderblock Please open an issue. This PR is not the right place to discuss such problems in depth.

cinderblock, benjamingr, and MoLow reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lyzadanger lyzadanger mentioned this pull request May 15, 2023
Change tests option from --watch to --live to avoid node conflict hypothesis/frontend-build#317
Merged
@richterdennis

richterdennis commented Nov 26, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

@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:
After some research I found out that fs.watch is reporting change events when a file gets read. I opened an issue for this: #50920

nchevsky reacted with thumbs up emoji cinderblock reacted with hooray emoji cinderblock reacted with heart emoji
All reactions
  • 👍 1 reaction
  • 🎉 1 reaction
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

claudioc
claudioc reviewed Dec 29, 2023
View reviewed changes
Comment thread lib/internal/main/watch_mode.js
}

async function restart() {
process.stdout.write(`${clear}${green}Restarting ${kCommandStr}${white}\n`);

@claudioc claudioc Dec 29, 2023

Copy link
Copy Markdown

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.

This "clear" should be at least configurable, as the --preserveWatchOutput option with tsc

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

danmichaelo, spidgorny, and SystemParadox reacted with thumbs up emoji
All reactions
  • 👍 3 reactions
Krinkle
Krinkle reviewed Jul 30, 2024
View reviewed changes
Comment thread doc/api/cli.md
$ node --watch-path=./src --watch-path=./tests index.js
```

This option is only supported on macOS and Windows.

@Krinkle Krinkle Jul 30, 2024

Copy link
Copy Markdown
Contributor

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.

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@opalmedapps-bot opalmedapps-bot mentioned this pull request Jan 28, 2025
chore: update node.js to v16.19.0 opalmedapps/docs#55
Closed
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell left review comments
@tniessen tniessen tniessen left review comments
@joyeecheung joyeecheung joyeecheung left review comments
@aduh95 aduh95 aduh95 approved these changes
@benjamingr benjamingr benjamingr approved these changes
+2 more reviewers
@Krinkle Krinkle Krinkle left review comments
@claudioc claudioc claudioc left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. experimental Issues and PRs related to experimental features. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version. watch-mode Issues and PRs related to watch mode.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

nodemon (or similar) in core

Uh oh!

There was an error while loading. Please reload this page.

15 participants

@MoLow @nodejs-github-bot @benjamingr @tniessen @joyeecheung @juanarbol @BobFrankston @mule-stand @cinderblock @richterdennis @Krinkle @claudioc @jasnell @aduh95 @RafaelGSS
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.