mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-19 01:06:36 +00:00
fix(GUI): ignore ECONNRESET and ECONNREFUSED when querying S3 (#1415)
Querying S3 to determine the latest available versions might throw `ECONNRESET` and `ECONNREFUSED`. This commit extends the `s3Packages.getRemoteVersions()` function to handle these errors and return no available version if so, like we already do with other similar HTTP errors. Change-Type: patch Changelog-Entry: Fix `ECONNRESET` and `ECONNREFUSED` errors when checking for updates on unstable connections. Fixes: https://github.com/resin-io/etcher/issues/1396 Fixes: https://github.com/resin-io/etcher/issues/1388 Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit is contained in:
parent
babe12cd7b
commit
b7f871607e
@ -148,6 +148,10 @@ exports.getRemoteVersions = _.memoize((bucketUrl) => {
|
||||
})
|
||||
.catch({
|
||||
code: 'ENOTFOUND'
|
||||
}, {
|
||||
code: 'ECONNRESET'
|
||||
}, {
|
||||
code: 'ECONNREFUSED'
|
||||
}, {
|
||||
code: 'ETIMEDOUT'
|
||||
}, () => {
|
||||
|
@ -643,6 +643,52 @@ describe('Shared: s3Packages', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('given ECONNRESET', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
const error = new Error('ECONNRESET');
|
||||
error.code = 'ECONNRESET';
|
||||
|
||||
this.requestGetAsyncStub = m.sinon.stub(request, 'getAsync');
|
||||
this.requestGetAsyncStub.returns(Bluebird.reject(error));
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.requestGetAsyncStub.restore();
|
||||
});
|
||||
|
||||
it('should resolve an empty array', function(done) {
|
||||
s3Packages.getRemoteVersions(s3Packages.BUCKET_URL.PRODUCTION).then((versions) => {
|
||||
m.chai.expect(versions).to.deep.equal([]);
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('given ECONNREFUSED', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
const error = new Error('ECONNREFUSED');
|
||||
error.code = 'ECONNREFUSED';
|
||||
|
||||
this.requestGetAsyncStub = m.sinon.stub(request, 'getAsync');
|
||||
this.requestGetAsyncStub.returns(Bluebird.reject(error));
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.requestGetAsyncStub.restore();
|
||||
});
|
||||
|
||||
it('should resolve an empty array', function(done) {
|
||||
s3Packages.getRemoteVersions(s3Packages.BUCKET_URL.PRODUCTION).then((versions) => {
|
||||
m.chai.expect(versions).to.deep.equal([]);
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('.getLatestVersion()', function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user