remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development
http://nodemon.io/
MIT License
26.23k stars 1.72k forks source link

Number of restart events differs from the number of exec. #2213

Closed novellat closed 1 month ago

novellat commented 1 month ago
const nodemon = require('nodemon');

nodemon({
  ext: 'js, jsx, ts, tsx, json, md',
  ignore: ['node_modules'],
  watch: ['./plugins'],
  exec: 'echo changed?????',
}).on('restart', (...args) => {
  console.log('CHANGE!!!!!!', args[0]);
});

Expected behaviour

expected the numbe of "changed?????" to be equal to "CHANGE!!!!!!".

Actual behaviour

But there's more restart events than the script calls.


remy commented 1 month ago

Possibly firing on overlapping triggers.

What's the actual impact of the problem you're seeing?

On Fri, 26 Jul 2024, 10:41 novellat, @.***> wrote:

  • Versions: @., @.
  • nodemon -v: 3.1.4
  • Operating system/terminal environment (powershell, gitshell, etc): zsh on mac
  • Using Docker? What image: no
  • Command you ran:

const nodemon = require('nodemon');

nodemon({ ext: 'js, jsx, ts, tsx, json, md', ignore: ['node_modules'], watch: ['./plugins'], exec: 'echo changed?????', }).on('restart', (...args) => { console.log('CHANGE!!!!!!', args[0]); });

Expected behaviour

expected the numbe of "changed?????" to be equal to "CHANGE!!!!!!". Actual behaviour

But there's more restart events than the script calls.

— Reply to this email directly, view it on GitHub https://github.com/remy/nodemon/issues/2213, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAADLBECMDR7YT5SITXFVR3ZOIKVDAVCNFSM6AAAAABLQFYFHWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZTCOBUGQ3TCNQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

novellat commented 1 month ago

The main thing is that I need to exec some relatively long running command on changes and would like to minimize the number of executions. So mostly performance impact (why run my long running command more than necessary)

novellat commented 1 month ago

What do you mean by overlapping triggers? I only have this one nodemon script running

novellat commented 1 month ago

Actually, feel free to close the ticket. I made a workaround around my problem - basically triggered several nodemons on different directories and then the whole logic is more straightforward and I don't need to any shenannigans like this, just a simple nodemon calls.