diff --git a/src/ui/public/saved_objects/__tests__/saved_objects_client.test.js b/src/ui/public/saved_objects/__tests__/saved_objects_client.test.js index feec586c5cb1d..4a8de1d12b5e9 100644 --- a/src/ui/public/saved_objects/__tests__/saved_objects_client.test.js +++ b/src/ui/public/saved_objects/__tests__/saved_objects_client.test.js @@ -128,6 +128,21 @@ describe('SavedObjectsClient', () => { await savedObjectsClient.get(doc.type, doc.id); sinon.assert.calledOnce(kfetchStub); }); + + test('handles HTTP call when it fails', async () => { + kfetchStub.withArgs({ + method: 'POST', + pathname: `/api/saved_objects/_bulk_get`, + query: undefined, + body: sinon.match.any + }).rejects(new Error('Request failed')); + try { + await savedObjectsClient.get(doc.type, doc.id); + throw new Error('should have error'); + } catch (e) { + expect(e.message).to.be('Request failed'); + } + }); }); describe('#delete', () => { diff --git a/src/ui/public/saved_objects/saved_objects_client.js b/src/ui/public/saved_objects/saved_objects_client.js index ac74db7060312..c18a7276ab804 100644 --- a/src/ui/public/saved_objects/saved_objects_client.js +++ b/src/ui/public/saved_objects/saved_objects_client.js @@ -215,6 +215,10 @@ export class SavedObjectsClient { queueItem.resolve(foundObject); }); + }).catch((err) => { + queue.forEach((queueItem) => { + queueItem.reject(err); + }); }); }, BATCH_INTERVAL, { leading: false });