Fix saving index pattern when there is a conflict (#21947)

This commit is contained in:
Jen Huang 2018-08-14 22:21:36 -07:00 committed by GitHub
parent e49d5f3b10
commit 341d5008dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -99,7 +99,9 @@ jest.mock('../../saved_objects', () => {
update: async (type, id, body, { version }) => {
if (object._version !== version) {
throw {
statusCode: 409
res: {
status: 409
}
};
}
@ -158,6 +160,6 @@ describe('IndexPattern', () => {
result = err;
}
expect(result.statusCode).toBe(409);
expect(result.res.status).toBe(409);
});
});

View file

@ -463,7 +463,7 @@ export function IndexPatternProvider(Private, config, Promise, confirmModalPromi
setVersion(this, _version);
})
.catch(err => {
if (err.statusCode === 409 && saveAttempts++ < MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS) {
if (_.get(err, 'res.status') === 409 && saveAttempts++ < MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS) {
const samePattern = new IndexPattern(this.id);
return samePattern.init()
.then(() => {