From 3a93313f75815b8cf26d056387f2553ab461c158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 28 Apr 2021 09:31:52 +0200 Subject: [PATCH] Frontend: Auto reload page when chunk is not found (#33445) --- .../DynamicImports/ErrorLoadingChunk.tsx | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/public/app/core/components/DynamicImports/ErrorLoadingChunk.tsx b/public/app/core/components/DynamicImports/ErrorLoadingChunk.tsx index 0d767b578fe..a235c9a415d 100644 --- a/public/app/core/components/DynamicImports/ErrorLoadingChunk.tsx +++ b/public/app/core/components/DynamicImports/ErrorLoadingChunk.tsx @@ -1,6 +1,7 @@ import React, { FunctionComponent } from 'react'; import { Button, stylesFactory } from '@grafana/ui'; import { css } from '@emotion/css'; +import { useUrlParams } from 'app/core/navigation/hooks'; const getStyles = stylesFactory(() => { return css` @@ -13,23 +14,32 @@ interface Props { error: Error | null; } -export const ErrorLoadingChunk: FunctionComponent = ({ error }) => ( -
-

Unable to find application file

-
-

Grafana has likely been updated. Please try reloading the page.

-
-
- -
-
- {error && error.message ? error.message : 'Unexpected error occurred'} +export const ErrorLoadingChunk: FunctionComponent = ({ error }) => { + const [params, updateUrlParams] = useUrlParams(); + + if (!params.get('chunkNotFound')) { + updateUrlParams({ chunkNotFound: true }, true); + window.location.reload(); + } + + return ( +
+

Unable to find application file


- {error && error.stack ? error.stack : null} -
-
-); +

Grafana has likely been updated. Please try reloading the page.

+
+
+ +
+
+ {error && error.message ? error.message : 'Unexpected error occurred'} +
+ {error && error.stack ? error.stack : null} +
+ + ); +}; ErrorLoadingChunk.displayName = 'ErrorLoadingChunk';