Background:
Salesforce is the base platform that is hosting the Form Assembly page within a Lightning component in a Lightning page. The page is loaded using secure parameters. The Form is actually presented within an iframe on the page. We are also using Purecloud Web Chat which is loaded onto the page via Google Tag Manager, which is loaded within the iframe.
Fault:
Web Chat sometimes fails to initialise and an error is observed in the browser console indicating a timeout (Uncaught (in promise) Error: Timed out after 10000ms trying to get time from https at jsapi-v1.js-async-cad67a8b.js:16).
Tracing the issue shows that Web Chat is initiating an additional (and in the case of Form Assembly pages, 2 additional) loads of the page. This is tracked back to the following code which is performing a page load in order to get the time from the Date response header:
$_mod_webchat.def("/get-origin-time$1.0.0/index", function(e, t, o, n, i) {
"use strict";
var r = window.location.origin;
o.exports = function() {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}
, t = e.url
, o = e.method
, n = e.timeout;
return t = t || r,
o = o || "HEAD",
n = n || 1e4,
new Promise(function(e, i) {
var r = new XMLHttpRequest
, u = void 0;
n > 0 && (u = setTimeout(function() {
i(new Error("Timed out after " + n + "ms trying to get time from " + t))
}, n)),
r.onload = function() {
var t = this.getResponseHeader("Date");
u && clearTimeout(u),
e(t)
}
,
r.onerror = function(e) {
u && clearTimeout(u),
i(e)
}
,
r.open(o, t),
r.send()
}
)
}
});
There is a 10 second guard timer on this fetch, which when combined with 2 fetches each taking roughly 6 seconds is exceeded and Web Chat fails to initialise.
The following image of the network trace shows the problem. At the top is the load from GTM, and at the bottom you can see two additional loads of the whole page that happen sequentially, each taking just over 5 seconds, which is enough to cause the following error:
Questions:
-
For a workaround we would like to extend the 10 second timer to 20 seconds to better handle slow loads from the server. Is it possible, and how/where to do that?
-
We would like to understand why there has to be additional loads of the whole page, especially why two of them
Any thoughts?
Thanks.