Dashboard: Ignore cancelled api request error when loading dashboard (#27232)

This commit is contained in:
Torkel Ödegaard 2020-08-27 08:55:26 +02:00 committed by GitHub
parent 1e8b10ef05
commit 5e27654298
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -214,7 +214,7 @@ describeInitScenario('Initializing home dashboard', ctx => {
describeInitScenario('Initializing home dashboard cancelled', ctx => {
ctx.setup(() => {
ctx.args.routeInfo = DashboardRouteInfo.Home;
ctx.backendSrv.get.mockResolvedValue([]);
ctx.backendSrv.get.mockRejectedValue({ cancelled: true });
});
it('Should abort init process', () => {

View File

@ -68,11 +68,6 @@ async function fetchDashboard(
// load home dash
const dashDTO: DashboardDTO = await backendSrv.get('/api/dashboards/home');
// if above all is cancelled it will return an array
if (Array.isArray(dashDTO)) {
return null;
}
// if user specified a custom home dashboard redirect to that
if (dashDTO.redirectUri) {
const newUrl = locationUtil.stripBaseFromUrl(dashDTO.redirectUri);
@ -116,6 +111,11 @@ async function fetchDashboard(
throw { message: 'Unknown route ' + args.routeInfo };
}
} catch (err) {
// Ignore cancelled errors
if (err.cancelled) {
return null;
}
dispatch(dashboardInitFailed({ message: 'Failed to fetch dashboard', error: err }));
console.error(err);
return null;