Skip to content

Commit 606acda

Browse files
committed
fix(EventuallyQueue): Poll against /health endpoint
1 parent 1abb841 commit 606acda

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/EventuallyQueue.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,14 @@ const EventuallyQueue = {
308308
}
309309
polling = setInterval(() => {
310310
const RESTController = CoreManager.getRESTController();
311-
RESTController.ajax('GET', CoreManager.get('SERVER_URL')).catch(error => {
312-
if (error !== 'Unable to connect to the Parse API') {
311+
RESTController.request('GET', 'health/')
312+
.then(() => {
313313
this.stopPoll();
314314
return this.sendQueue();
315-
}
316-
});
315+
})
316+
.catch(() => {
317+
// 'Unable to connect to the Parse API' keep polling
318+
});
317319
}, ms);
318320
},
319321

src/__tests__/EventuallyQueue-test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ const RESTController = require('../RESTController');
5252
const Storage = require('../Storage');
5353
const mockXHR = require('./test_helpers/mockXHR');
5454

55+
CoreManager.setInstallationController({
56+
currentInstallationId() {
57+
return Promise.resolve('iid');
58+
},
59+
});
60+
5561
function flushPromises() {
5662
return new Promise(resolve => setImmediate(resolve));
5763
}
@@ -400,7 +406,7 @@ describe('EventuallyQueue', () => {
400406

401407
it('can poll server', async () => {
402408
jest.spyOn(EventuallyQueue, 'sendQueue').mockImplementationOnce(() => {});
403-
RESTController._setXHR(mockXHR([{ status: 107, response: { error: 'ok' } }]));
409+
RESTController._setXHR(mockXHR([{ status: 200, response: {} }]));
404410
EventuallyQueue.poll();
405411
expect(EventuallyQueue.isPolling()).toBe(true);
406412
jest.runOnlyPendingTimers();

0 commit comments

Comments
 (0)