From 49ec721bd6e5d0bd35bbf8f447634d3aef3fff61 Mon Sep 17 00:00:00 2001 From: Tim Hostetler Date: Fri, 21 Jul 2017 12:37:24 -0400 Subject: [PATCH 1/2] Update Jquery Paths for 404/500 --- src/404.html | 3 ++- src/500.html | 3 ++- src/js/apps/discovery/main.js | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/404.html b/src/404.html index f5d2ef4cf..1ca4e9a88 100644 --- a/src/404.html +++ b/src/404.html @@ -7,7 +7,8 @@ require.config({ paths: { 'google-analytics': '//www.google-analytics.com/analytics', - 'analytics': 'js/components/analytics' + 'analytics': 'js/components/analytics', + 'jquery': '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min' }, map: { 'analytics': { diff --git a/src/500.html b/src/500.html index c0a88357d..00d926adf 100644 --- a/src/500.html +++ b/src/500.html @@ -7,7 +7,8 @@ require.config({ paths: { 'google-analytics': '//www.google-analytics.com/analytics', - 'analytics': 'js/components/analytics' + 'analytics': 'js/components/analytics', + 'jquery': '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min' }, map: { 'analytics': { diff --git a/src/js/apps/discovery/main.js b/src/js/apps/discovery/main.js index 1d71111b4..84c36d289 100644 --- a/src/js/apps/discovery/main.js +++ b/src/js/apps/discovery/main.js @@ -81,7 +81,7 @@ define(['config', 'module'], function(config, module) { } }).fail(function () { - app.redirect('/500.html'); + app.redirect('500.html'); }); }).fail(function() { @@ -90,7 +90,7 @@ define(['config', 'module'], function(config, module) { return } // if we failed loading, retry *once again* (and give up eventually) - app.reload('/404.html'); + app.reload('404.html'); }); }); From a6a5ea2fcb92f0fb8de0041bbaeef0c477569feb Mon Sep 17 00:00:00 2001 From: Tim Hostetler Date: Fri, 21 Jul 2017 12:37:44 -0400 Subject: [PATCH 2/2] Fix Timeouts For Bootstrap Request - Added `timeout` param for api request builder - Provided a custom timeout for bootstrapping request, so it fails properly --- src/js/mixins/discovery_bootstrap.js | 19 ++++++++++--------- src/js/services/api.js | 6 +++++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/js/mixins/discovery_bootstrap.js b/src/js/mixins/discovery_bootstrap.js index 72cf0367c..4131221c8 100644 --- a/src/js/mixins/discovery_bootstrap.js +++ b/src/js/mixins/discovery_bootstrap.js @@ -80,6 +80,7 @@ define([ // XXX:rca - solve this better, through config var beehive = this.getBeeHive(); var dynConf = this.getObject('DynamicConfig'); + var timeout = 3000; var defer = $.Deferred(); @@ -103,7 +104,8 @@ define([ pendingReqs--; if (pendingReqs <= 0) defer.resolve(retVal); }, - type: 'GET' + type: 'GET', + timeout: timeout - 1 }; var redirect_uri = location.origin + location.pathname; @@ -125,17 +127,16 @@ define([ }); setTimeout(function() { - if (defer.state() == 'resolved') - return; - defer.reject(); - }, - 3000); + if (defer.state() === 'resolved') { + return; + } + defer.reject(); + }, timeout); } else { setTimeout(function() { - defer.resolve({}), - 1 - }); + defer.resolve({}); + }, 1); } return defer; }, diff --git a/src/js/services/api.js b/src/js/services/api.js index b1517bdce..8e885c400 100644 --- a/src/js/services/api.js +++ b/src/js/services/api.js @@ -143,9 +143,13 @@ define([ context: {request: request, api: self }, timeout: this.defaultTimeoutInMs, headers: {}, - cache: true, // do not generate _ parameters (let browser cache responses), + cache: true // do not generate _ parameters (let browser cache responses), }; + if (options.timeout) { + opts.timeout = options.timeout; + } + if (this.clientVersion) { opts.headers['X-BB-Api-Client-Version'] = this.clientVersion; }