Commit 5e276542 by Torkel Ödegaard Committed by GitHub

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

parent 1e8b10ef
...@@ -214,7 +214,7 @@ describeInitScenario('Initializing home dashboard', ctx => { ...@@ -214,7 +214,7 @@ describeInitScenario('Initializing home dashboard', ctx => {
describeInitScenario('Initializing home dashboard cancelled', ctx => { describeInitScenario('Initializing home dashboard cancelled', ctx => {
ctx.setup(() => { ctx.setup(() => {
ctx.args.routeInfo = DashboardRouteInfo.Home; ctx.args.routeInfo = DashboardRouteInfo.Home;
ctx.backendSrv.get.mockResolvedValue([]); ctx.backendSrv.get.mockRejectedValue({ cancelled: true });
}); });
it('Should abort init process', () => { it('Should abort init process', () => {
......
...@@ -68,11 +68,6 @@ async function fetchDashboard( ...@@ -68,11 +68,6 @@ async function fetchDashboard(
// load home dash // load home dash
const dashDTO: DashboardDTO = await backendSrv.get('/api/dashboards/home'); 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 user specified a custom home dashboard redirect to that
if (dashDTO.redirectUri) { if (dashDTO.redirectUri) {
const newUrl = locationUtil.stripBaseFromUrl(dashDTO.redirectUri); const newUrl = locationUtil.stripBaseFromUrl(dashDTO.redirectUri);
...@@ -116,6 +111,11 @@ async function fetchDashboard( ...@@ -116,6 +111,11 @@ async function fetchDashboard(
throw { message: 'Unknown route ' + args.routeInfo }; throw { message: 'Unknown route ' + args.routeInfo };
} }
} catch (err) { } catch (err) {
// Ignore cancelled errors
if (err.cancelled) {
return null;
}
dispatch(dashboardInitFailed({ message: 'Failed to fetch dashboard', error: err })); dispatch(dashboardInitFailed({ message: 'Failed to fetch dashboard', error: err }));
console.error(err); console.error(err);
return null; return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment