node-elasticsearch-client
node-elasticsearch-client copied to clipboard
Error callback calls twice if host is inaccessible
Hi, if server is not available error callback will be called twice: first time after TIMEOUT and second time later. I return response to user in error callback, so in this case response will be returned twice.
Script example: http://pastebin.com/X1d8j0S9 Run and open in browser http://localhost:8888/ :
user@localhost ~ $ node es.js
Listen...
ERROR [Error: timed out after 5000ms] <-- timeout is 5s
ERROR { [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect' } <-- ~30s later when socket was closed (?)
I tried abort the request before emitting timeout error (elasticSearchCall.js:50), but second error still raised.