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

Improve error handling of sync with better errors #961

Merged
merged 1 commit into from
Apr 11, 2017
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
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