From c53fa0e80d3e05c10c160e94dc602ea1937094bd Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Fri, 24 Mar 2023 10:46:58 -0700 Subject: [PATCH 01/12] Store pusherSocketID to send with requests --- src/libs/Pusher/pusher.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/Pusher/pusher.js b/src/libs/Pusher/pusher.js index 2483a0c5e3f3..c14f4152f6c0 100644 --- a/src/libs/Pusher/pusher.js +++ b/src/libs/Pusher/pusher.js @@ -17,6 +17,7 @@ Onyx.connect({ }); let socket; +let pusherSocketID = ''; const socketEventCallbacks = []; let customAuthorizer; @@ -64,6 +65,7 @@ function init(args, params) { } socket = new Pusher(args.appKey, options); + pusherSocketID = socket.connection.socket_id; // If we want to pass params in our requests to api.php we'll need to add it to socket.config.auth.params // as per the documentation @@ -355,6 +357,7 @@ function disconnect() { socket.disconnect(); socket = null; + pusherSocketID = ''; } /** @@ -393,4 +396,5 @@ export { registerSocketEventCallback, registerCustomAuthorizer, TYPE, + pusherSocketID, }; From 4bc9d6f5a9a79af9df13c6dac16171660b27255f Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Fri, 24 Mar 2023 10:50:17 -0700 Subject: [PATCH 02/12] Lint, export getPusherSocketID vs mutable export --- src/libs/Pusher/pusher.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libs/Pusher/pusher.js b/src/libs/Pusher/pusher.js index c14f4152f6c0..bb7f0980923f 100644 --- a/src/libs/Pusher/pusher.js +++ b/src/libs/Pusher/pusher.js @@ -374,6 +374,13 @@ function reconnect() { socket.connect(); } +/** + * @returns {String} + */ +function getPusherSocketID() { + return pusherSocketID; +} + if (window) { /** * Pusher socket for debugging purposes @@ -396,5 +403,5 @@ export { registerSocketEventCallback, registerCustomAuthorizer, TYPE, - pusherSocketID, + getPusherSocketID, }; From 9731a172875eccba31a97371a3ebd374307089e0 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Fri, 24 Mar 2023 11:58:18 -0700 Subject: [PATCH 03/12] Send socket id in requests to fix replay effect --- src/libs/HttpUtils.js | 16 ++++++++++++++++ src/libs/Pusher/pusher.js | 14 +++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/libs/HttpUtils.js b/src/libs/HttpUtils.js index d3322733e253..c697e89a53f9 100644 --- a/src/libs/HttpUtils.js +++ b/src/libs/HttpUtils.js @@ -24,6 +24,9 @@ let cancellationController = new AbortController(); // To terminate pending ReconnectApp requests https://github.com/Expensify/App/issues/15627 let reconnectAppCancellationController = new AbortController(); +// An ID for this client's Pusher socket. When Pusher is initialized it will set this value and it will be sent with all requests. +let pusherSocketID = ''; + /** * Send an HTTP request, and attempt to resolve the json response. * If there is a network error, we'll set the application offline. @@ -117,6 +120,11 @@ function xhr(command, data, type = CONST.NETWORK.METHOD.POST, shouldUseSecure = formData.append(key, val); }); + // We send the pusherSocketID with all requests so that the api can include it with push events to prevent Pusher from sending the events to that client. The push event is sent back + // to the requesting client in the response data instead, which prevents a replay effect. See https://github.com/Expensify/App/issues/12775. + if (!_.isEmpty(pusherSocketID)) { + formData.append('pusherSocketID', pusherSocketID); + } const url = ApiUtils.getCommandURL({shouldUseSecure, command}); return processHTTPRequest(url, type, formData, data.canCancel, command); } @@ -135,8 +143,16 @@ function cancelPendingRequests() { cancelPendingReconnectAppRequest(); } +/** + * @param {String} value The pusherSocketID + */ +function setPusherSocketID(value) { + pusherSocketID = value; +} + export default { xhr, cancelPendingRequests, cancelPendingReconnectAppRequest, + setPusherSocketID, }; diff --git a/src/libs/Pusher/pusher.js b/src/libs/Pusher/pusher.js index bb7f0980923f..af88f0b90b65 100644 --- a/src/libs/Pusher/pusher.js +++ b/src/libs/Pusher/pusher.js @@ -4,6 +4,7 @@ import ONYXKEYS from '../../ONYXKEYS'; import Pusher from './library'; import TYPE from './EventType'; import Log from '../Log'; +import HttpUtils from '../HttpUtils'; let shouldForceOffline = false; Onyx.connect({ @@ -17,7 +18,6 @@ Onyx.connect({ }); let socket; -let pusherSocketID = ''; const socketEventCallbacks = []; let customAuthorizer; @@ -65,7 +65,7 @@ function init(args, params) { } socket = new Pusher(args.appKey, options); - pusherSocketID = socket.connection.socket_id; + HttpUtils.setPusherSocketID(socket.connection.socket_id); // If we want to pass params in our requests to api.php we'll need to add it to socket.config.auth.params // as per the documentation @@ -357,7 +357,7 @@ function disconnect() { socket.disconnect(); socket = null; - pusherSocketID = ''; + HttpUtils.setPusherSocketID(''); } /** @@ -374,13 +374,6 @@ function reconnect() { socket.connect(); } -/** - * @returns {String} - */ -function getPusherSocketID() { - return pusherSocketID; -} - if (window) { /** * Pusher socket for debugging purposes @@ -403,5 +396,4 @@ export { registerSocketEventCallback, registerCustomAuthorizer, TYPE, - getPusherSocketID, }; From 237abd1d7e958aca551d7271b6009f6e6e6aee8a Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Fri, 24 Mar 2023 12:34:38 -0700 Subject: [PATCH 04/12] Create actions to queue onyx updates --- src/ONYXKEYS.js | 3 +++ src/libs/actions/QueuedOnyxUpdates.js | 32 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/libs/actions/QueuedOnyxUpdates.js diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 42a4a2d651be..049ae0418a84 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -24,6 +24,9 @@ export default { // Note: These are Persisted Requests - not all requests in the main queue as the key name might lead one to believe PERSISTED_REQUESTS: 'networkRequestQueue', + // Onyx updates from a response, or success or failure data from a request. + QUEUED_ONYX_UPDATES: 'queuedOnyxUpdates', + // Stores current date CURRENT_DATE: 'currentDate', diff --git a/src/libs/actions/QueuedOnyxUpdates.js b/src/libs/actions/QueuedOnyxUpdates.js new file mode 100644 index 000000000000..d0215a1227d5 --- /dev/null +++ b/src/libs/actions/QueuedOnyxUpdates.js @@ -0,0 +1,32 @@ +import Onyx from 'react-native-onyx'; +import ONYXKEYS from '../../ONYXKEYS'; + +let queuedOnyxUpdates = []; +Onyx.connect({ + key: ONYXKEYS.QUEUED_ONYX_UPDATES, + callback: val => queuedOnyxUpdates = val || [], +}); + +/** + * @param {Array} updates Onyx updates to queue for later + */ +function queueOnyxUpdates(updates) { + Onyx.merge(ONYXKEYS.QUEUED_ONYX_UPDATES, updates); +} + +function clear() { + Onyx.set(ONYXKEYS.QUEUED_ONYX_UPDATES, null); +} + +/** + * @returns {Array} + */ +function getQueuedUpdates() { + return queuedOnyxUpdates; +} + +export { + queueOnyxUpdates, + clear, + getQueuedUpdates, +}; From 3e6f2a4487dd32a7d94e730332321a1ed12ccc35 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Fri, 24 Mar 2023 12:50:30 -0700 Subject: [PATCH 05/12] pusherSocketID is only needed in write requests --- src/libs/API.js | 5 +++++ src/libs/HttpUtils.js | 16 ---------------- src/libs/Pusher/pusher.js | 14 +++++++++++--- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/libs/API.js b/src/libs/API.js index d86fc099a08a..13ec04b40087 100644 --- a/src/libs/API.js +++ b/src/libs/API.js @@ -4,6 +4,7 @@ import * as Request from './Request'; import * as SequentialQueue from './Network/SequentialQueue'; import pkg from '../../package.json'; import CONST from '../CONST'; +import * as Pusher from './Pusher/pusher'; /** * All calls to API.write() will be persisted to disk as JSON with the params, successData, and failureData. @@ -29,6 +30,10 @@ function write(command, apiCommandParameters = {}, onyxData = {}) { ...apiCommandParameters, appversion: pkg.version, apiRequestType: CONST.API_REQUEST_TYPE.WRITE, + + // We send the pusherSocketID with all write requests so that the api can include it in push events to prevent Pusher from sending the events to that client. The push event is sent + // back to the requesting client in the response data instead, which prevents a replay effect in the UI. See https://github.com/Expensify/App/issues/12775. + pusherSocketID: Pusher.getPusherSocketID(), }; // Assemble all the request data we'll be storing in the queue diff --git a/src/libs/HttpUtils.js b/src/libs/HttpUtils.js index c697e89a53f9..d3322733e253 100644 --- a/src/libs/HttpUtils.js +++ b/src/libs/HttpUtils.js @@ -24,9 +24,6 @@ let cancellationController = new AbortController(); // To terminate pending ReconnectApp requests https://github.com/Expensify/App/issues/15627 let reconnectAppCancellationController = new AbortController(); -// An ID for this client's Pusher socket. When Pusher is initialized it will set this value and it will be sent with all requests. -let pusherSocketID = ''; - /** * Send an HTTP request, and attempt to resolve the json response. * If there is a network error, we'll set the application offline. @@ -120,11 +117,6 @@ function xhr(command, data, type = CONST.NETWORK.METHOD.POST, shouldUseSecure = formData.append(key, val); }); - // We send the pusherSocketID with all requests so that the api can include it with push events to prevent Pusher from sending the events to that client. The push event is sent back - // to the requesting client in the response data instead, which prevents a replay effect. See https://github.com/Expensify/App/issues/12775. - if (!_.isEmpty(pusherSocketID)) { - formData.append('pusherSocketID', pusherSocketID); - } const url = ApiUtils.getCommandURL({shouldUseSecure, command}); return processHTTPRequest(url, type, formData, data.canCancel, command); } @@ -143,16 +135,8 @@ function cancelPendingRequests() { cancelPendingReconnectAppRequest(); } -/** - * @param {String} value The pusherSocketID - */ -function setPusherSocketID(value) { - pusherSocketID = value; -} - export default { xhr, cancelPendingRequests, cancelPendingReconnectAppRequest, - setPusherSocketID, }; diff --git a/src/libs/Pusher/pusher.js b/src/libs/Pusher/pusher.js index af88f0b90b65..bb7f0980923f 100644 --- a/src/libs/Pusher/pusher.js +++ b/src/libs/Pusher/pusher.js @@ -4,7 +4,6 @@ import ONYXKEYS from '../../ONYXKEYS'; import Pusher from './library'; import TYPE from './EventType'; import Log from '../Log'; -import HttpUtils from '../HttpUtils'; let shouldForceOffline = false; Onyx.connect({ @@ -18,6 +17,7 @@ Onyx.connect({ }); let socket; +let pusherSocketID = ''; const socketEventCallbacks = []; let customAuthorizer; @@ -65,7 +65,7 @@ function init(args, params) { } socket = new Pusher(args.appKey, options); - HttpUtils.setPusherSocketID(socket.connection.socket_id); + pusherSocketID = socket.connection.socket_id; // If we want to pass params in our requests to api.php we'll need to add it to socket.config.auth.params // as per the documentation @@ -357,7 +357,7 @@ function disconnect() { socket.disconnect(); socket = null; - HttpUtils.setPusherSocketID(''); + pusherSocketID = ''; } /** @@ -374,6 +374,13 @@ function reconnect() { socket.connect(); } +/** + * @returns {String} + */ +function getPusherSocketID() { + return pusherSocketID; +} + if (window) { /** * Pusher socket for debugging purposes @@ -396,4 +403,5 @@ export { registerSocketEventCallback, registerCustomAuthorizer, TYPE, + getPusherSocketID, }; From 38a565320bcc52b1584509e48242c4f8f82432f9 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Fri, 24 Mar 2023 13:23:39 -0700 Subject: [PATCH 06/12] Queue then update Onyx after SequentialQueue flush --- src/libs/Middleware/SaveResponseInOnyx.js | 15 ++++++++++++--- src/libs/Network/SequentialQueue.js | 2 ++ src/libs/actions/QueuedOnyxUpdates.js | 3 ++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/libs/Middleware/SaveResponseInOnyx.js b/src/libs/Middleware/SaveResponseInOnyx.js index 08e24c1d7843..73dd5f5333eb 100644 --- a/src/libs/Middleware/SaveResponseInOnyx.js +++ b/src/libs/Middleware/SaveResponseInOnyx.js @@ -1,4 +1,6 @@ import Onyx from 'react-native-onyx'; +import CONST from '../../CONST'; +import * as QueuedOnyxUpdates from '../actions/QueuedOnyxUpdates'; /** * @param {Promise} response @@ -13,19 +15,26 @@ function SaveResponseInOnyx(response, request) { return; } + // For most requests we can immediately update Onyx. For write requests we queue the updates and apply them after the sequential queue has flushed to prevent a replay effect in + // the UI. See https://github.com/Expensify/App/issues/12775 for more info. + let updateHandler = Onyx.update; + if (request.data.requestType === CONST.API_REQUEST_TYPE.WRITE) { + updateHandler = QueuedOnyxUpdates.queueOnyxUpdates; + } + // First apply any onyx data updates that are being sent back from the API. We wait for this to complete and then // apply successData or failureData. This ensures that we do not update any pending, loading, or other UI states contained // in successData/failureData until after the component has received and API data. const onyxDataUpdatePromise = responseData.onyxData - ? Onyx.update(responseData.onyxData) + ? updateHandler(responseData.onyxData) : Promise.resolve(); onyxDataUpdatePromise.then(() => { // Handle the request's success/failure data (client-side data) if (responseData.jsonCode === 200 && request.successData) { - Onyx.update(request.successData); + updateHandler(request.successData); } else if (responseData.jsonCode !== 200 && request.failureData) { - Onyx.update(request.failureData); + updateHandler(request.failureData); } }); diff --git a/src/libs/Network/SequentialQueue.js b/src/libs/Network/SequentialQueue.js index b0aa9224fb8d..298b4014c422 100644 --- a/src/libs/Network/SequentialQueue.js +++ b/src/libs/Network/SequentialQueue.js @@ -7,6 +7,7 @@ import * as ActiveClientManager from '../ActiveClientManager'; import * as Request from '../Request'; import * as RequestThrottle from '../RequestThrottle'; import CONST from '../../CONST'; +import * as QueuedOnyxUpdates from '../actions/QueuedOnyxUpdates'; let resolveIsReadyPromise; let isReadyPromise = new Promise((resolve) => { @@ -80,6 +81,7 @@ function flush() { isSequentialQueueRunning = false; resolveIsReadyPromise(); currentRequest = null; + Onyx.update(QueuedOnyxUpdates.getQueuedUpdates()).then(QueuedOnyxUpdates.clear); }); }, }); diff --git a/src/libs/actions/QueuedOnyxUpdates.js b/src/libs/actions/QueuedOnyxUpdates.js index d0215a1227d5..593b2c3d6c51 100644 --- a/src/libs/actions/QueuedOnyxUpdates.js +++ b/src/libs/actions/QueuedOnyxUpdates.js @@ -9,9 +9,10 @@ Onyx.connect({ /** * @param {Array} updates Onyx updates to queue for later + * @returns {Promise} */ function queueOnyxUpdates(updates) { - Onyx.merge(ONYXKEYS.QUEUED_ONYX_UPDATES, updates); + return Onyx.merge(ONYXKEYS.QUEUED_ONYX_UPDATES, updates); } function clear() { From b057930de057ccff488037ef71ff550429341f32 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Mon, 10 Apr 2023 16:00:07 -0700 Subject: [PATCH 07/12] socket_id is only available once connected --- src/libs/Pusher/pusher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Pusher/pusher.js b/src/libs/Pusher/pusher.js index bb7f0980923f..16ddb9a15b08 100644 --- a/src/libs/Pusher/pusher.js +++ b/src/libs/Pusher/pusher.js @@ -65,7 +65,6 @@ function init(args, params) { } socket = new Pusher(args.appKey, options); - pusherSocketID = socket.connection.socket_id; // If we want to pass params in our requests to api.php we'll need to add it to socket.config.auth.params // as per the documentation @@ -83,6 +82,7 @@ function init(args, params) { }); socket.connection.bind('connected', () => { + pusherSocketID = socket.connection.socket_id; callSocketEventCallbacks('connected'); resolve(); }); From c6d10bd3a06f5a4a6b08bee3c39a01634559802e Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Mon, 10 Apr 2023 17:19:26 -0700 Subject: [PATCH 08/12] Properly check apiRequestType --- src/libs/Middleware/SaveResponseInOnyx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Middleware/SaveResponseInOnyx.js b/src/libs/Middleware/SaveResponseInOnyx.js index 73dd5f5333eb..f3f5095793c0 100644 --- a/src/libs/Middleware/SaveResponseInOnyx.js +++ b/src/libs/Middleware/SaveResponseInOnyx.js @@ -18,7 +18,7 @@ function SaveResponseInOnyx(response, request) { // For most requests we can immediately update Onyx. For write requests we queue the updates and apply them after the sequential queue has flushed to prevent a replay effect in // the UI. See https://github.com/Expensify/App/issues/12775 for more info. let updateHandler = Onyx.update; - if (request.data.requestType === CONST.API_REQUEST_TYPE.WRITE) { + if (request.data.apiRequestType === CONST.API_REQUEST_TYPE.WRITE) { updateHandler = QueuedOnyxUpdates.queueOnyxUpdates; } From 3c7e9f9d7113744172631a279dea3b7ddd921715 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Tue, 18 Apr 2023 15:27:40 -0700 Subject: [PATCH 09/12] Handle all updates before clearing queued updates --- src/libs/Middleware/SaveResponseInOnyx.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libs/Middleware/SaveResponseInOnyx.js b/src/libs/Middleware/SaveResponseInOnyx.js index f3f5095793c0..5b689de59245 100644 --- a/src/libs/Middleware/SaveResponseInOnyx.js +++ b/src/libs/Middleware/SaveResponseInOnyx.js @@ -29,16 +29,16 @@ function SaveResponseInOnyx(response, request) { ? updateHandler(responseData.onyxData) : Promise.resolve(); - onyxDataUpdatePromise.then(() => { + return onyxDataUpdatePromise.then(() => { // Handle the request's success/failure data (client-side data) if (responseData.jsonCode === 200 && request.successData) { - updateHandler(request.successData); - } else if (responseData.jsonCode !== 200 && request.failureData) { - updateHandler(request.failureData); + return updateHandler(request.successData); } - }); - - return responseData; + if (responseData.jsonCode !== 200 && request.failureData) { + return updateHandler(request.failureData); + } + return Promise.resolve(); + }).then(() => responseData); }); } From eb74861a6814fdd39d7b13d45aaa6beb1d69b211 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Tue, 25 Apr 2023 15:17:09 -0700 Subject: [PATCH 10/12] Add file description comment per checklist --- src/libs/actions/QueuedOnyxUpdates.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/actions/QueuedOnyxUpdates.js b/src/libs/actions/QueuedOnyxUpdates.js index 593b2c3d6c51..c89ae1053d60 100644 --- a/src/libs/actions/QueuedOnyxUpdates.js +++ b/src/libs/actions/QueuedOnyxUpdates.js @@ -1,6 +1,8 @@ import Onyx from 'react-native-onyx'; import ONYXKEYS from '../../ONYXKEYS'; +// In this file we manage a queue of Onyx updates while the SequentialQueue is processing. There are functions to get the updates and clear the queue after saving the updates in Onyx. + let queuedOnyxUpdates = []; Onyx.connect({ key: ONYXKEYS.QUEUED_ONYX_UPDATES, From 2fabf6e4beac9a0b3a3ab021fed937b38b9ed98d Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Mon, 1 May 2023 10:33:54 -0700 Subject: [PATCH 11/12] Small cleanup from review feedback --- src/libs/API.js | 4 ++-- src/libs/Middleware/SaveResponseInOnyx.js | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libs/API.js b/src/libs/API.js index 13ec04b40087..cbc5a7ba0869 100644 --- a/src/libs/API.js +++ b/src/libs/API.js @@ -31,8 +31,8 @@ function write(command, apiCommandParameters = {}, onyxData = {}) { appversion: pkg.version, apiRequestType: CONST.API_REQUEST_TYPE.WRITE, - // We send the pusherSocketID with all write requests so that the api can include it in push events to prevent Pusher from sending the events to that client. The push event is sent - // back to the requesting client in the response data instead, which prevents a replay effect in the UI. See https://github.com/Expensify/App/issues/12775. + // We send the pusherSocketID with all write requests so that the api can include it in push events to prevent Pusher from sending the events to the requesting client. The push event + // is sent back to the requesting client in the response data instead, which prevents a replay effect in the UI. See https://github.com/Expensify/App/issues/12775. pusherSocketID: Pusher.getPusherSocketID(), }; diff --git a/src/libs/Middleware/SaveResponseInOnyx.js b/src/libs/Middleware/SaveResponseInOnyx.js index 5b689de59245..817c206413af 100644 --- a/src/libs/Middleware/SaveResponseInOnyx.js +++ b/src/libs/Middleware/SaveResponseInOnyx.js @@ -17,10 +17,7 @@ function SaveResponseInOnyx(response, request) { // For most requests we can immediately update Onyx. For write requests we queue the updates and apply them after the sequential queue has flushed to prevent a replay effect in // the UI. See https://github.com/Expensify/App/issues/12775 for more info. - let updateHandler = Onyx.update; - if (request.data.apiRequestType === CONST.API_REQUEST_TYPE.WRITE) { - updateHandler = QueuedOnyxUpdates.queueOnyxUpdates; - } + const updateHandler = request.data.apiRequestType === CONST.API_REQUEST_TYPE.WRITE ? QueuedOnyxUpdates.queueOnyxUpdates : Onyx.update; // First apply any onyx data updates that are being sent back from the API. We wait for this to complete and then // apply successData or failureData. This ensures that we do not update any pending, loading, or other UI states contained From 6a42b9a918ff72852ceaa26273734c07d24ededd Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Thu, 4 May 2023 12:22:17 -0700 Subject: [PATCH 12/12] Process and update Onyx only if requests exist --- src/libs/Network/SequentialQueue.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Network/SequentialQueue.js b/src/libs/Network/SequentialQueue.js index 298b4014c422..b17e4ec7b8fd 100644 --- a/src/libs/Network/SequentialQueue.js +++ b/src/libs/Network/SequentialQueue.js @@ -54,7 +54,7 @@ function process() { } function flush() { - if (isSequentialQueueRunning) { + if (isSequentialQueueRunning || _.isEmpty(PersistedRequests.getAll())) { return; }