From 25ec4c353e7f285e7895279eee6f747c7c2948ec Mon Sep 17 00:00:00 2001 From: dplewis Date: Wed, 15 Jul 2020 15:22:32 -0500 Subject: [PATCH] Fix: Live Query Subscription Error Event Similar to https://github.com/parse-community/Parse-SDK-JS/pull/1151 --- src/LiveQueryClient.js | 2 +- src/__tests__/LiveQueryClient-test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/LiveQueryClient.js b/src/LiveQueryClient.js index 2ad463543..cdcfe2efc 100644 --- a/src/LiveQueryClient.js +++ b/src/LiveQueryClient.js @@ -381,7 +381,7 @@ class LiveQueryClient extends EventEmitter { if (data.requestId) { if (subscription) { subscription.subscribePromise.resolve(); - subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error); + setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error), 200); } } else { this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error); diff --git a/src/__tests__/LiveQueryClient-test.js b/src/__tests__/LiveQueryClient-test.js index 476fdcb0f..844620c49 100644 --- a/src/__tests__/LiveQueryClient-test.js +++ b/src/__tests__/LiveQueryClient-test.js @@ -244,6 +244,7 @@ describe('LiveQueryClient', () => { liveQueryClient._handleWebSocketMessage(event); + jest.runOnlyPendingTimers(); expect(isChecked).toBe(true); });