mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Fix saved objects client _processBatchQueue function to handle errors (#26763)
* Fix saved objects client _processBatchQueue function to handle errors * Fix error thrown in try/catch
This commit is contained in:
parent
5ed3233fdd
commit
44f976b42c
2 changed files with 19 additions and 0 deletions
|
@ -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', () => {
|
||||
|
|
|
@ -215,6 +215,10 @@ export class SavedObjectsClient {
|
|||
|
||||
queueItem.resolve(foundObject);
|
||||
});
|
||||
}).catch((err) => {
|
||||
queue.forEach((queueItem) => {
|
||||
queueItem.reject(err);
|
||||
});
|
||||
});
|
||||
|
||||
}, BATCH_INTERVAL, { leading: false });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue