node-etcd icon indicating copy to clipboard operation
node-etcd copied to clipboard

Broken response in watcher doesn't back off

Open ptte opened this issue 12 years ago • 1 comments

If the watcher catches a change and the response is broken, or for some reason can't be parsed, but the etcd server still responds with something, we end up in an endless loop.

It seems to me like it should use the _retry method here instead of directly calling _watch here https://github.com/stianeikeland/node-etcd/blob/master/src/watcher.coffee#L51

else
    error = new Error 'Received unexpected response'
    error.response = val;
    @emit 'error', error
    @_watch()

Behaviour we're experiencing is that it retries every tick, which crashes the server by using all available cpu.

At the same time, a back off algorithm would be nice. :)

ptte avatar Jul 23 '14 22:07 ptte

Thanks for PR, merged in https://github.com/stianeikeland/node-etcd/commit/39ea3456656e0a20f4f41042ae65e5042798f3bd :)

stianeikeland avatar Jul 27 '14 19:07 stianeikeland