fix(GUI): catch EACCES when querying S3 packages (#1463)

When the user is behind a firewall, then the HTTP request to query the
latest available version from S3 may throw an EACCES error, eventually
causing a confusin "You don't have access to this resource" error
window.

Change-Type: patch
Changelog-Entry: Fix "You don't have access to this resource" error at startup when behind a firewall.
Fixes: https://github.com/resin-io/etcher/issues/1458
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit is contained in:
Juan Cruz Viotti 2017-05-20 14:47:50 -04:00 committed by GitHub
parent 78f36dfd16
commit 705e273400
2 changed files with 25 additions and 0 deletions

View File

@ -152,6 +152,8 @@ exports.getRemoteVersions = _.memoize((bucketUrl) => {
code: 'ECONNRESET'
}, {
code: 'ECONNREFUSED'
}, {
code: 'EACCES'
}, {
code: 'ETIMEDOUT'
}, () => {

View File

@ -689,6 +689,29 @@ describe('Shared: s3Packages', function() {
});
describe('given EACCES', function() {
beforeEach(function() {
const error = new Error('EACCES');
error.code = 'EACCES';
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() {