Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable ajax timeout option #2864

Merged
merged 2 commits into from
Jul 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/ajax.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {parse as parseURL, format as formatURL} from './url';
import { config } from 'src/config';

var utils = require('./utils');

Expand Down Expand Up @@ -51,9 +52,13 @@ 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
if (!config.getConfig('disableAjaxTimeout')) {
x.ontimeout = function () {
utils.logError(' xhr timeout after ', x.timeout, 'ms');
};
}

if (method === 'GET' && data) {
let urlInfo = parseURL(url, options);
Expand All @@ -63,7 +68,10 @@ 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
if (!config.getConfig('disableAjaxTimeout')) {
x.timeout = timeout;
}

if (options.withCredentials) {
x.withCredentials = true;
Expand Down
9 changes: 9 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down