From bdb475146c4e01e150c6caad8d0957b9c8c91f2b Mon Sep 17 00:00:00 2001 From: Jaimin Panchal Date: Wed, 18 Jul 2018 17:15:57 -0400 Subject: [PATCH 1/2] disable timeout --- src/ajax.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index e17f782ac30..9d8072f8ca9 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -51,9 +51,11 @@ export function ajaxBuilder(timeout = 3000, {request, done} = {}) { } } }; - x.ontimeout = function () { - utils.logError(' xhr timeout after ', x.timeout, 'ms'); - }; + + // Disabled timeout temporarily to avoid xhr failed requests. https://github.com/prebid/Prebid.js/issues/2648 + // x.ontimeout = function () { + // utils.logError(' xhr timeout after ', x.timeout, 'ms'); + // }; if (method === 'GET' && data) { let urlInfo = parseURL(url, options); @@ -63,7 +65,8 @@ export function ajaxBuilder(timeout = 3000, {request, done} = {}) { x.open(method, url); // IE needs timoeut to be set after open - see #1410 - x.timeout = timeout; + // Disabled timeout temporarily to avoid xhr failed requests. https://github.com/prebid/Prebid.js/issues/2648 + // x.timeout = timeout; if (options.withCredentials) { x.withCredentials = true; From be380ff1693946eba68099e57d141bedb5a9d9f5 Mon Sep 17 00:00:00 2001 From: Jaimin Panchal Date: Thu, 19 Jul 2018 10:28:36 -0400 Subject: [PATCH 2/2] add config to disable timeout --- src/ajax.js | 13 +++++++++---- src/config.js | 9 +++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index 9d8072f8ca9..1916f4ea080 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -1,4 +1,5 @@ import {parse as parseURL, format as formatURL} from './url'; +import { config } from 'src/config'; var utils = require('./utils'); @@ -53,9 +54,11 @@ export function ajaxBuilder(timeout = 3000, {request, done} = {}) { }; // Disabled timeout temporarily to avoid xhr failed requests. https://github.com/prebid/Prebid.js/issues/2648 - // x.ontimeout = function () { - // utils.logError(' xhr timeout after ', x.timeout, 'ms'); - // }; + if (!config.getConfig('disableAjaxTimeout')) { + x.ontimeout = function () { + utils.logError(' xhr timeout after ', x.timeout, 'ms'); + }; + } if (method === 'GET' && data) { let urlInfo = parseURL(url, options); @@ -66,7 +69,9 @@ export function ajaxBuilder(timeout = 3000, {request, done} = {}) { x.open(method, url); // IE needs timoeut to be set after open - see #1410 // Disabled timeout temporarily to avoid xhr failed requests. https://github.com/prebid/Prebid.js/issues/2648 - // x.timeout = timeout; + if (!config.getConfig('disableAjaxTimeout')) { + x.timeout = timeout; + } if (options.withCredentials) { x.withCredentials = true; diff --git a/src/config.js b/src/config.js index c4be2cd552b..f8d8195409b 100644 --- a/src/config.js +++ b/src/config.js @@ -18,6 +18,7 @@ const DEFAULT_BIDDER_TIMEOUT = 3000; const DEFAULT_PUBLISHER_DOMAIN = window.location.origin; const DEFAULT_COOKIESYNC_DELAY = 100; const DEFAULT_ENABLE_SEND_ALL_BIDS = true; +const DEFAULT_DISABLE_AJAX_TIMEOUT = false; const DEFAULT_TIMEOUTBUFFER = 200; @@ -163,6 +164,14 @@ export function newConfig() { this._timoutBuffer = val; }, + _disableAjaxTimeout: DEFAULT_DISABLE_AJAX_TIMEOUT, + get disableAjaxTimeout() { + return this._disableAjaxTimeout; + }, + set disableAjaxTimeout(val) { + this._disableAjaxTimeout = val; + }, + }; function hasGranularity(val) {