From 450ce513fe693cf6951e70f29e8e3b1353ec99e7 Mon Sep 17 00:00:00 2001 From: Daniel Brain Date: Mon, 31 Jul 2017 23:44:01 -0700 Subject: [PATCH] Make message response timeout logic less frequent --- src/conf/config.js | 2 +- src/public/client.js | 37 ++++++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/conf/config.js b/src/conf/config.js index 081a00ec..188ea3b4 100644 --- a/src/conf/config.js +++ b/src/conf/config.js @@ -11,7 +11,7 @@ export let CONFIG : Object = { BRIDGE_TIMEOUT: 5000, ACK_TIMEOUT: 1000, - RES_TIMEOUT: __TEST__ ? 2000 : 10000, + RES_TIMEOUT: __TEST__ ? 2000 : Infinity, LOG_TO_PAGE: false, diff --git a/src/public/client.js b/src/public/client.js index 5d4f6feb..6c2f5051 100644 --- a/src/public/client.js +++ b/src/public/client.js @@ -7,7 +7,7 @@ import { getAncestor, isAncestor, isWindowClosed } from 'cross-domain-utils/src' import { CONFIG, CONSTANTS } from '../conf'; import { sendMessage, addResponseListener, deleteResponseListener } from '../drivers'; import { type ResponseListenerType } from '../drivers'; -import { uniqueID, safeInterval, onWindowReady } from '../lib'; +import { uniqueID, onWindowReady } from '../lib'; import { global } from '../global'; global.requestPromises = global.requestPromises || new WeakMap(); @@ -137,14 +137,15 @@ export function request(options : RequestOptionsType) : ZalgoPromise { + let cycleTime = 100; - if (responseListener.ack && hasResult) { - return interval.cancel(); + let cycle = () => { + + if (hasResult) { + return; } if (isWindowClosed(win)) { - interval.cancel(); if (!responseListener.ack) { return reject(new Error(`Window closed for ${name} before ack`)); @@ -153,20 +154,30 @@ export function request(options : RequestOptionsType) : ZalgoPromise