message: Favor async/await over promise chains.
diff: @@ -146,8 +146,11 @@ const actions = {
  * 1. the WS closes abnormally
  * 2. the WS can not establish a connection within $TIMEOUT
  */
  - const pollAndWatch = () => (delete POLLs[id]) && incrementallyLoad()
  - .then(resourceVersion => {
  + const pollAndWatch = async () => {
  + delete POLLs[id];
  +
  + try {
  + const resourceVersion = await incrementallyLoad();
  // ensure this watch should still exist because pollAndWatch is recursiveish
  if (!REF_COUNTS[id]) {
  // eslint-disable-next-line no-console
  @@ -165,6 +168,23 @@ const actions = {
  const {subProtocols} = getState().UI.get('impersonate', {});
  WS[id] = k8sWatch(k8skind, {...query, resourceVersion}, {subProtocols, timeout: 60 * 1000});
  + } catch (e) {
  + if (!REF_COUNTS[id]) {
  + // eslint-disable-next-line no-console
  + console.log(`stopped watching ${id} before finishing incremental loading with error ${e}!`);
  + // call cleanup function out of abundance of caution...
  + dispatch(actions.stopK8sWatch(id));
  + return;
  + }
  +
  + dispatch(actions.errored(id, e));
  +
  + if (!POLLs[id]) {
  + POLLs[id] = setTimeout(pollAndWatch, 15 * 1000);
  + }
  + return;
  + }
  +
  WS[id]
  .onclose(event => {
  // Close Frame Status Codes: https://tools.ietf.org/html/rfc6455#section-7.4.1
  @@ -195,22 +215,7 @@ const actions = {
  POLLs[id] = setTimeout(pollAndWatch, 15 * 1000);
  })
  .onbulkmessage(events => dispatch(actions.updateListFromWS(id, events)));
  - },
  - e => {
  - if (!REF_COUNTS[id]) {
  - // eslint-disable-next-line no-console
  - console.log(`stopped watching ${id} before finishing incremental loading with error ${e}!`);
  - // call cleanup function out of abundance of caution...
  - dispatch(actions.stopK8sWatch(id));
  - return;
  - }
  - dispatch(actions.errored(id, e));
  - if (POLLs[id]) {
  - return;
  - }
  - POLLs[id] = setTimeout(pollAndWatch, 15 * 1000);
  - });
  -
  + };
  pollAndWatch();
  },
  };
  