fix(s3): Fix EAI_AGAIN error at startup with no internet connection (#1855)

Change-type: patch
This commit is contained in:
Andrew Scheller 2017-11-17 11:22:22 +00:00 committed by GitHub
parent 66cb7293e7
commit 701893b472
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -160,6 +160,8 @@ exports.getRemoteVersions = _.memoize((bucketUrl) => {
}, {
code: 'EHOSTDOWN'
}, {
code: 'EAI_AGAIN'
}, {
// May happen when behind a proxy
code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'

View File

@ -649,6 +649,28 @@ describe('Shared: s3Packages', function () {
})
})
describe('given EAI_AGAIN', function () {
beforeEach(function () {
const error = new Error('EAI_AGAIN')
error.code = 'EAI_AGAIN'
this.requestGetAsyncStub = m.sinon.stub(request, 'getAsync')
this.requestGetAsyncStub.returns(Bluebird.reject(error))
})
afterEach(function () {
this.requestGetAsyncStub.restore()
})
it('should be rejected with a user error with code UPDATE_USER_ERROR', function (done) {
s3Packages.getRemoteVersions(s3Packages.BUCKET_URL.PRODUCTION).catch((error) => {
m.chai.expect(errors.isUserError(error)).to.be.true
m.chai.expect(error.code).to.equal('UPDATE_USER_ERROR')
done()
})
})
})
describe('given ECONNRESET', function () {
beforeEach(function () {
const error = new Error('ECONNRESET')