Report what went wrong when refreshAccessToken fails

This commit is contained in:
Thomas Goyne 2017-08-31 10:50:23 -07:00
parent 6d5fec23e2
commit 0c4430d234
1 changed files with 5 additions and 4 deletions

View File

@ -75,8 +75,6 @@ function refreshAccessToken(user, localRealmPath, realmUrl) {
headers: postHeaders headers: postHeaders
}; };
performFetch(url, options) performFetch(url, options)
// in case something lower in the HTTP stack breaks, try again in 10 seconds
.catch(() => setTimeout(() => refreshAccessToken(user, localRealmPath, realmUrl), 10 * 1000))
.then((response) => response.json().then((json) => { return { response, json }; })) .then((response) => response.json().then((json) => { return { response, json }; }))
.then((responseAndJson) => { .then((responseAndJson) => {
const response = responseAndJson.response; const response = responseAndJson.response;
@ -112,7 +110,11 @@ function refreshAccessToken(user, localRealmPath, realmUrl) {
} }
} }
}) })
.catch((e) => print_error(e)); .catch((e) => {
print_error(e);
// in case something lower in the HTTP stack breaks, try again in 10 seconds
setTimeout(() => refreshAccessToken(user, localRealmPath, realmUrl), 10 * 1000);
})
} }
/** /**
@ -291,7 +293,6 @@ const instanceMethods = {
throw new AuthError(body); throw new AuthError(body);
}); });
} else { } else {
return response.json(); return response.json();
} }
}); });