diff --git a/lib/aws.js b/lib/aws.js index 0ad6aba..7d3c609 100644 --- a/lib/aws.js +++ b/lib/aws.js @@ -33,17 +33,17 @@ function checkCredentials(obj, cb) { if (obj.secretAccessKey == null || obj.accessKeyId == null || lapse > 0) { var md = metadata.init(); md().call({endpoint: 'iam/security-credentials/'}, function(err, res) { - if (err) cb(err); - if (typeof res === 'undefined') cb(new Error('metadata API response undefined')); + if (err) return cb(err); + if (typeof res === 'undefined') return cb(new Error('metadata API response undefined')); md().call({endpoint: 'iam/security-credentials/' + res.split('\n')[0]}, function(err, res) { try { res = JSON.parse(res); } catch(e) { - cb(e); + return cb(e); } if (res.SecretAccessKey === null) - cb(new Error("secretAccessKey and accessKeyId not provided and could not be determined.")); + return cb(new Error("secretAccessKey and accessKeyId not provided and could not be determined.")); obj.secretAccessKey = res.SecretAccessKey; obj.accessKeyId = res.AccessKeyId; obj.token = res.Token;