Skip to content

node --watch --watch-path #55189

Closed as not planned
Closed as not planned

Description

@0xMIEL

Version

v20.17.0

Platform

Linux 5d46ffbf9811 6.10.4-linuxkit #1 SMP Mon Aug 12 08:47:01 UTC 2024 aarch64 Linux

Subsystem

docker

What steps will reproduce the bug?

I’m using node --watch --watch-path in Docker, and it works great until after a few runs, it gets stuck and displays the message ‘Waiting for graceful termination.’

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

I’m using node --watch --watch-flag in Docker, and it works great. However, with every start, after Node refreshes the code a few times, it gets stuck and the message ‘Waiting for graceful termination.’ appears.

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

With each run, when node refreshes the code several times

What do you see instead?

Screenshot 2024-09-30 at 20 56 17

Additional information

No response

Activity

  1. avivkeller commented on Sep 30, 2024

    @avivkeller
    Member

    Are you able to reproduce outside of Docker? I can't seem to reproduce locally.

  2. 0xMIEL commented on Sep 30, 2024

    @0xMIEL
    Author

    Yes, I was able to reproduce this error when I edited the http server.
    Screenshot 2024-09-30 at 22 24 49

  3. geeksilva97 commented on Oct 7, 2024

    @geeksilva97
    Contributor

    I tried to reproduce it on branch v20.17.0 but I couldn't.

    My env: Darwin LM-JNVH7RPW6J 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6030 arm64.

    I executed the following script to change the server.js thousands of times but I couldn't see this Waiting for graceful termination message.

    import { writeFileSync } from 'fs';
    
    const fileContentVersion1 = `import http from 'http';
    
    const server = http.createServer((req, res) => {
      res.writeHead(200, { 'Content-Type': 'text/plain' });
      res.end('First version');
    });
    
    server.listen(1234, () => {
      console.log('Server is running at http://localhost:1234/', (new Date()).toString());
    });
    `;
    
    const fileContentVersion2 = `import http from 'http';
    
    const server = http.createServer((req, res) => {
      res.writeHead(200, { 'Content-Type': 'text/plain' });
      res.end('New version');
    });
    
    server.listen(1234, () => {
      console.log('Server is running at http://localhost:1234/', (new Date()).toString());
    });
    `;
    
    const versions = [fileContentVersion1, fileContentVersion2];
    let counter = 0;
    
    setInterval(() => {
      writeFileSync('./server.js', versions[counter++ % 2]);
      if(counter % 1000  === 0) console.log('File updated', { counter });
    }, 200);

    Command

    ./node --watch ./server.js --watch-path=./
    
  4. avivkeller commented on Oct 8, 2024

    @avivkeller
    Member

    As this cannot be reproduce, I've closed this issue. If this changes, I'll adjust the issue.

  5. muratgozel commented on Nov 29, 2024

    @muratgozel

    im having a similar issue in my computer (macos and no docker). i have this simple command
    infisical run --env=${INFISICAL_ENV:-dev} -- node --watch --watch-path dist --enable-source-maps dist/index.js
    and after certain amount of time it says "Waiting for graceful termination..." and doesn't reflect the updates. looks like the exec having a timeout? it shouldn't timeout because it has a server running inside. (No problem in production which the server started with node --enable-source-maps index.js)

  6. OliverJAsh commented on Feb 18, 2025

    @OliverJAsh

    I'm running into a similar issue. Curiously, removing --watch and only specifying --watch-path fixes the issue for me. Does that work for anyone else?

    This might be related as well: #57124

  7. RB-Lab commented on Aug 30, 2025

    @RB-Lab

    I had similar issue. I turned out, that I had a highly optimized http connection hanging and undici didn't want to close before the timeout (which was 5 min in my case) runs out. So for now I replaced httpClient.close() with process.exit(0):

        // was
        process.on('SIGTERM', async () => {
            await httpClient.close()
        })
        // now
        process.on('SIGTERM', () => {
            process.exit(0)
        })

    This probably will backfire at some point, but for now it solves the problem.

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