From b78171dda5d5a7c412e6894dbfa99c964b94fc5f Mon Sep 17 00:00:00 2001 From: jpage Date: Tue, 4 Oct 2016 21:01:58 -0700 Subject: [PATCH] Missing once wrappers Some of the request types do not have the `once` wrappers that others do. Notably, we encountered an issue with `.list()` where certain errors, like `EHOSTUNREACH`, cause double callbacks. --- .gitignore | 1 + lib/client.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index f571ee4..f61be4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /test/auth.json /node_modules/ /npm-debug.log +.idea diff --git a/lib/client.js b/lib/client.js index ea2b3ed..7167f1b 100644 --- a/lib/client.js +++ b/lib/client.js @@ -568,6 +568,7 @@ Client.prototype.getFile = function(filename, headers, fn){ } var req = this.get(filename, headers); + fn = once(fn); registerReqListeners(req, fn); req.end(); return req; @@ -783,6 +784,7 @@ Client.prototype.list = function(params, headers, fn){ var url = params ? '?' + qs.stringify(params) : ''; var req = this.request('GET', url, headers); + fn = once(fn); registerReqListeners(req, function(err, res){ if (err) return fn(err);