Report what went wrong when refreshAccessToken fails

This commit is contained in:
Thomas Goyne 2017-08-31 10:50:23 -07:00
parent e75496571f
commit 26b4cdf33f

View File

@ -74,8 +74,6 @@ function refreshAccessToken(user, localRealmPath, realmUrl) {
headers: postHeaders
};
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((responseAndJson) => {
const response = responseAndJson.response;
@ -111,7 +109,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);
})
}
function _authenticate(userConstructor, server, json, callback) {
@ -253,7 +255,6 @@ module.exports = {
throw new AuthError(body);
});
} else {
return response.json();
}
});