Skip to content
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

--watch-path doesn't run the JavaScript file #47296

Closed
ksmithut opened this issue Mar 29, 2023 · 3 comments · Fixed by #47369
Closed

--watch-path doesn't run the JavaScript file #47296

ksmithut opened this issue Mar 29, 2023 · 3 comments · Fixed by #47369
Labels
watch-mode Issues and PRs related to watch mode

Comments

@ksmithut
Copy link

Version

v19.8.1

Platform

Darwin [redacted] 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:35 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T8103 arm64

Subsystem

command line options?

What steps will reproduce the bug?

With this file as index.js:

console.log('hello')

Run any of the following commands:

node --watch-path=./index.js index.js
node --watch-path=./ index.js
node --watch-path=./index.js --watch index.js
node --watch-path=./index.js --watch-preserve-output index.js

How often does it reproduce? Is there a required condition?

Every time

What is the expected behavior? Why is that the expected behavior?

I would expect the index.js file to run and "hello" be printed to the screen every time the file changes.

What do you see instead?

I see the messages of Restarting index.js, but no hello.

Additional information

No response

@MoLow MoLow added the watch-mode Issues and PRs related to watch mode label Mar 29, 2023
@debadree25
Copy link
Member

I think we can mark this confirmed bug too? I am trying to take a shot at this

@echocrow
Copy link

echocrow commented Mar 30, 2023

Ran into this issue as well when executing node --watch-path some/path my/file.js.

From what I'm seeing, --watch-path ... does execute the root file.
However, the console output (or at least stdout) is omitted and not shown in the console.

Addendum:

  • Also running Node v19.8.1.
  • Running node --watch my/file.js does show the desired stdout.

@debadree25
Copy link
Member

debadree25 commented Apr 1, 2023

I think the problem lies of over here

const stdio = kShouldFilterModules ? ['inherit', 'inherit', 'inherit', 'ipc'] : undefined;

its possible i think when watch mode is running with --watch-path the child process is not connected to the parent process and hence the console logs are lost? not sure though what exactly could be the right options it seems passing 'inherit' makes it get stuck in a infinite loop

cc @MoLow

nodejs-github-bot pushed a commit that referenced this issue Apr 5, 2023
PR-URL: #47369
Fixes: #47296
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
RafaelGSS pushed a commit that referenced this issue Apr 5, 2023
PR-URL: #47369
Fixes: #47296
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
RafaelGSS pushed a commit that referenced this issue Apr 5, 2023
PR-URL: #47369
Fixes: #47296
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
RafaelGSS pushed a commit that referenced this issue Apr 6, 2023
PR-URL: #47369
Fixes: #47296
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
RafaelGSS pushed a commit that referenced this issue Apr 7, 2023
PR-URL: #47369
Fixes: #47296
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
RafaelGSS pushed a commit that referenced this issue Apr 8, 2023
PR-URL: #47369
Fixes: #47296
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
RafaelGSS pushed a commit that referenced this issue Apr 13, 2023
PR-URL: #47369
Fixes: #47296
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
danielleadams pushed a commit that referenced this issue Jul 6, 2023
PR-URL: #47369
Fixes: #47296
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
MoLow added a commit to MoLow/node that referenced this issue Jul 6, 2023
PR-URL: nodejs#47369
Fixes: nodejs#47296
Reviewed-By: Debadree Chatterjee <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
watch-mode Issues and PRs related to watch mode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants