Skip to content

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

Description

@ksmithut

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

Activity

  1. debadree25 commented on Mar 29, 2023

    @debadree25
    Contributor

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

  2. echocrow commented on Mar 30, 2023

    @echocrow

    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.
  3. debadree25 commented on Apr 1, 2023

    @debadree25
    Contributor

    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

  4. added a commit that references this issue on Jul 6, 2023
  5. added a commit that references this issue on Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    watch-modeIssues and PRs related to watch mode.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions