You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ro...@apache.org on 2021/05/06 02:35:32 UTC

[superset] branch master updated: Attempt to reduce asyncEvent test flakiness (#14497)

This is an automated email from the ASF dual-hosted git repository.

robdiciuccio pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new fa0915d  Attempt to reduce asyncEvent test flakiness (#14497)
fa0915d is described below

commit fa0915d9e6e774dd600ac92cec426da96f05d481
Author: Rob DiCiuccio <ro...@gmail.com>
AuthorDate: Wed May 5 19:34:13 2021 -0700

    Attempt to reduce asyncEvent test flakiness (#14497)
---
 superset-frontend/src/middleware/asyncEvent.ts | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/superset-frontend/src/middleware/asyncEvent.ts b/superset-frontend/src/middleware/asyncEvent.ts
index aafd7fc..28dd77e 100644
--- a/superset-frontend/src/middleware/asyncEvent.ts
+++ b/superset-frontend/src/middleware/asyncEvent.ts
@@ -56,13 +56,15 @@ const RETRY_DELAY = 100;
 
 let config: AppConfig;
 let transport: string;
-let polling_delay: number;
+let pollingDelayMs: number;
+let pollingTimeoutId: number;
 let listenersByJobId: Record<string, ListenerFn>;
 let retriesByJobId: Record<string, number>;
 let lastReceivedEventId: string | null | undefined;
 
 export const init = (appConfig?: AppConfig) => {
   if (!isFeatureEnabled(FeatureFlag.GLOBAL_ASYNC_QUERIES)) return;
+  if (pollingTimeoutId) clearTimeout(pollingTimeoutId);
 
   listenersByJobId = {};
   retriesByJobId = {};
@@ -84,7 +86,7 @@ export const init = (appConfig?: AppConfig) => {
     }
   }
   transport = config.GLOBAL_ASYNC_QUERIES_TRANSPORT || TRANSPORT_POLLING;
-  polling_delay = config.GLOBAL_ASYNC_QUERIES_POLLING_DELAY || 500;
+  pollingDelayMs = config.GLOBAL_ASYNC_QUERIES_POLLING_DELAY || 500;
 
   try {
     lastReceivedEventId = localStorage.getItem(LOCALSTORAGE_KEY);
@@ -185,7 +187,7 @@ const loadEventsFromApi = async () => {
   }
 
   if (transport === TRANSPORT_POLLING) {
-    setTimeout(loadEventsFromApi, polling_delay);
+    pollingTimeoutId = window.setTimeout(loadEventsFromApi, pollingDelayMs);
   }
 };