{"action":"opened","issue":{"url":"https://api.github.com/repos/nodecg/nodecg/issues/101","labels_url":"https://api.github.com/repos/nodecg/nodecg/issues/101/labels{/name}","comments_url":"https://api.github.com/repos/nodecg/nodecg/issues/101/comments","events_url":"https://api.github.com/repos/nodecg/nodecg/issues/101/events","html_url":"https://github.com/nodecg/nodecg/issues/101","id":58524530,"number":101,"title":"Make watcher handle rapid file changes better","user":{"login":"Lange","id":873012,"avatar_url":"https://avatars.githubusercontent.com/u/873012?v=3","gravatar_id":"","url":"https://api.github.com/users/Lange","html_url":"https://github.com/Lange","followers_url":"https://api.github.com/users/Lange/followers","following_url":"https://api.github.com/users/Lange/following{/other_user}","gists_url":"https://api.github.com/users/Lange/gists{/gist_id}","starred_url":"https://api.github.com/users/Lange/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lange/subscriptions","organizations_url":"https://api.github.com/users/Lange/orgs","repos_url":"https://api.github.com/users/Lange/repos","events_url":"https://api.github.com/users/Lange/events{/privacy}","received_events_url":"https://api.github.com/users/Lange/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-22T22:45:46Z","updated_at":"2015-02-22T22:45:46Z","closed_at":null,"body":"The watcher's current behavior is to react to any change in a bundle's files, with the exception of the contents of the `view` folder. This is suboptimal, as many events such installing/uninstalling a bundle or running `git pull` will cause the parser to run dozens or hundreds of times in a fraction of a second. This can actually crash or deadlock small VPSes with limited RAM, as each cycle of the parser could potentially spin up an instance of npm and/or bower.\r\n\r\nThe watcher should instead have some kind of backoff algorithm:\r\n 1. The watcher detects a file change, and it triggers the parser to reload the bundle\r\n 2. A timer is started\r\n 3. If any further changes happen while this timer is running, the timer is reset and nothing else happens.\r\n 4. Once the timer expires, and if any changes beyond the initial one were made, reload the bundle once more.\r\n\r\nThis has the benefit of still being instant for developers making small changes to single files, while not crashing the system when dragging dozens or hundreds of files into the `bundles` folder. The duration of the timer doesn't need to be long, I think 100ms might be a good starting point to test with."}}