mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: Ignore cancelled api request error when loading dashboard (#27232)
This commit is contained in:
parent
1e8b10ef05
commit
5e27654298
@ -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', () => {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user