Skip to content

Nodemon waits forever for subprocesses to end #1633

@jaybeeuu

Description

@jaybeeuu
  • nodemon -v: 2.0.0
  • node -v: 12.13.1
  • Operating system/terminal environment: Ubuntu 18.04.3 LTS/bash
  • Using Docker? What image:
  • Command you ran: nodemon --exec 'npm run-script start'

Expected behaviour

Restarting a process with the --exec command cleanly terminates the existing processes and restarts the supplied command.

Actual behaviour

When restarting a process, such as a node.js express server which has been started using the --exec option nodemon gets into an infinite loop, waiting for subprocesses to finish. Reporting

[nodemon] still waiting for 2 subprocess(es) to finish...

continually in the console, interleaved with the normal messaging for restarting the process.

Steps to reproduce

I have created a basic repro repo here:

https://github.com/jayseeare/nodemon-bug-repro

Running npm run debug and making a change in index.js will exhibit the problem.

Running npm run watch in the same repro does not exhibit the behaviour, and nor does running the same command with nodemon pinned to v1.19.1.

From the message and the versions I suspect this PR as having introduced the problem.


[nodemon] 2.0.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] watching extensions: js,mjs,json
--------------
node: v12.13.1
nodemon: 2.0.0
command: /home/josh/.nvm/versions/node/v12.13.1/bin/node /home/josh/src/nodemon-bug-repro/node_modules/.bin/nodemon --exec npm run-script start --dump
cwd: /home/josh/src/nodemon-bug-repro
OS: linux x64
--------------
{
  run: false,
  system: { cwd: '/home/josh/src/nodemon-bug-repro' },
  required: false,
  dirs: [ '/home/josh/src/nodemon-bug-repro' ],
  timeout: 1000,
  options: {
    exec: 'npm run-script start',
    dump: true,
    ignore: [
      '**/.git/**',
      '**/.nyc_output/**',
      '**/.sass-cache/**',
      '**/bower_components/**',
      '**/coverage/**',
      '**/node_modules/**',
      re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*/
    ],
    watch: [ '*.*', re: /.*\..*/ ],
    ignoreRoot: [
      '**/.git/**',
      '**/.nyc_output/**',
      '**/.sass-cache/**',
      '**/bower_components/**',
      '**/coverage/**',
      '**/node_modules/**'
    ],
    restartable: 'rs',
    colours: true,
    execMap: { py: 'python', rb: 'ruby', ts: 'ts-node' },
    stdin: true,
    runOnChangeOnly: false,
    verbose: false,
    signal: 'SIGUSR2',
    stdout: true,
    watchOptions: {},
    execOptions: {
      script: null,
      exec: 'npm run-script start',
      args: [],
      scriptPosition: null,
      nodeArgs: undefined,
      execArgs: [],
      ext: 'js,mjs,json',
      env: {}
    },
    monitor: [
      '*.*',
      '!**/.git/**',
      '!**/.nyc_output/**',
      '!**/.sass-cache/**',
      '!**/bower_components/**',
      '!**/coverage/**',
      '!**/node_modules/**'
    ]
  },
  load: [Function],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [],
  watchInterval: null,
  signal: 'SIGUSR2',
  command: {
    raw: { executable: 'npm run-script start', args: [] },
    string: 'npm run-script start'
  }
}
--------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions