Skip to content

Commit

Permalink
improve error handling of sync with better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
luisrudge authored and Unknown committed Apr 11, 2017
1 parent 1539e05 commit d1dc865
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
17 changes: 9 additions & 8 deletions src/engine/classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,24 @@ class Classic {
}

render(m) {
//if there's an error, we should show the error screen no matter what.
if (l.hasStopped(m)) {
return new ErrorScreen();
}

// TODO: remove the detail about the loading pane being pinned,
// sticky screens should be handled at the box module.
if (!isDone(m) || m.get("isLoadingPanePinned")) {
return new LoadingScreen();
}

if (l.hasStopped(m)) {
return new ErrorScreen();
}

if (hasScreen(m, "login")) {
if (!hasSkippedQuickAuth(m)
&& hasInitialScreen(m, "login")) {
&& hasInitialScreen(m, "login")) {

if (isInCorpNetwork(m)) {
return new KerberosScreen();
}
if (isInCorpNetwork(m)) {
return new KerberosScreen();
}

if (l.ui.rememberLastLogin(m)) {
const conn = lastUsedConnection(m);
Expand Down
2 changes: 1 addition & 1 deletion src/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function handleError(m, key, error) {

// TODO: this should be configurable for each sync
if (key !== "sso") {
const stopError = new Error(`An error occurred when fetching data. (key: ${key})`);
const stopError = new Error(`An error occurred when fetching ${key} data for Lock: ${error.message}`);
stopError.code = "sync";
stopError.origin = error;
result = l.stop(result, stopError);
Expand Down
8 changes: 4 additions & 4 deletions src/utils/cdn_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ export function load(attrs) {
script.src = url;
global.document.getElementsByTagName('head')[0].appendChild(script);

const handleError = (url) => {
const handleError = (err) => {
cbs[method] = cbs[method].filter(x => {
if (x.url === url) {
setTimeout(() => x.cb({}), 0);
setTimeout(() => x.cb(err), 0);
return false;
} else {
return true;
}
});
}

const timeoutID = setTimeout(() => handleError(url), 5000);
const timeoutID = setTimeout(() => handleError(new Error(`${url} timed out`)), 20000);

script.addEventListener('load', () => clearTimeout(timeoutID));

script.addEventListener('error', () => {
clearTimeout(timeoutID);
handleError(url);
handleError(new Error(`${url} could not be loaded.`));
});
}

Expand Down

0 comments on commit d1dc865

Please sign in to comment.