From 2c79d38caeb350edf1bc3affe5557af0d4f36ba0 Mon Sep 17 00:00:00 2001 From: Lukas Brabec Date: Jan 21 2021 16:13:16 +0000 Subject: don't fail when server is unreachable --- diff --git a/src/actions/reduxActions.js b/src/actions/reduxActions.js index 24157b3..488a75c 100644 --- a/src/actions/reduxActions.js +++ b/src/actions/reduxActions.js @@ -31,6 +31,7 @@ export const loadUser = payload => (dispatch, getState) => { forUser: payload, data: data })) + dispatch(setServerError(false)) // retry after 10s if fetched data not complete // and user has not changed meanwhile @@ -43,7 +44,10 @@ export const loadUser = payload => (dispatch, getState) => { }) .catch((error) => { console.error('Error:', error); - dispatch(throwError({error: error, reason: ActionTypes.LOAD_USER})) + //dispatch(throwError({error: error, reason: ActionTypes.LOAD_USER})) + //server-side error, retry in 60s + dispatch(setServerError(true)) + setTimeout(() => dispatch(loadUser(payload)), 60000) }); } @@ -180,3 +184,8 @@ export const setDepGraph = payload => ({ type: ActionTypes.SET_DEP_GRAPH, payload: payload }) + +export const setServerError = payload => ({ + type: ActionTypes.SET_SERVER_ERROR, + payload: payload +}) diff --git a/src/components/Dashboard.js b/src/components/Dashboard.js index 9e47dfb..1b36ee7 100644 --- a/src/components/Dashboard.js +++ b/src/components/Dashboard.js @@ -56,7 +56,12 @@ class Dashboard extends Component { this.props.user_data === undefined || // mind the order (lazy eval) this.props.user_data.static_info.status !== 200 ) { - return + return + {this.props.server_error? +

Unable to reach server, retrying in 60 seconds

+ : + null} +
} if (this.props.user_data.static_info.data.packages.length === 0) { @@ -67,7 +72,8 @@ class Dashboard extends Component { const { options, releases, } = this.props const { show_groups, show_schedule } = options - const isLoading = bzs.status !== 200 || prs.status !== 200 || static_info.status !== 200 + const isLoading = this.props.server_error || + bzs.status !== 200 || prs.status !== 200 || static_info.status !== 200 if (!isLoading){ if (this.refreshInterval === undefined){ console.log(`Spawning periodic refersh, interval is ${window.env.REFRESH_INTERVAL/1000} seconds.`) @@ -157,7 +163,7 @@ class Dashboard extends Component { isLoading={isLoading} stats={filteredCntPerCat} /> - {isLoading ? + {isLoading && !this.props.server_error ?
It appears you are newcomer or haven't visited the Fedora Packager Dashboard in the last {this.props.caching_info.visits_required_every_n_days} days. @@ -181,7 +187,7 @@ class Dashboard extends Component { } const mapStateToProps = (state) => { - const { user_data, fasuser, options, releases, caching_info } = state + const { user_data, fasuser, options, releases, caching_info, server_error } = state return { user_data, @@ -189,6 +195,7 @@ const mapStateToProps = (state) => { options, releases, caching_info, + server_error, } } diff --git a/src/components/DashboardLoading.js b/src/components/DashboardLoading.js index 7af2fb5..bc91388 100644 --- a/src/components/DashboardLoading.js +++ b/src/components/DashboardLoading.js @@ -8,8 +8,8 @@ class DashboardLoading extends Component {

- {this.props.children}

+ {this.props.children}
diff --git a/src/components/Stats.js b/src/components/Stats.js index 615e100..3974c1c 100644 --- a/src/components/Stats.js +++ b/src/components/Stats.js @@ -41,6 +41,12 @@ class Stats extends PureComponent { data-original-title={`${this.props.shownPackages} packages shown`}> {this.props.shownPackages} + {this.props.server_error? + + + Unable to reach server + + : null} {spinner}
@@ -151,13 +157,14 @@ const StatIcon = connect((state) => ({ }))(_StatIcon) const mapStateToProps = (state) => { - const { user_data, fasuser, options, releases } = state + const { user_data, fasuser, options, releases, server_error } = state return { user_data, fasuser, options, releases, + server_error, } } diff --git a/src/constants/index.js b/src/constants/index.js index aa9ef92..80fd7b6 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -16,4 +16,5 @@ export default { LOAD_CACHING_INFO_RESP: 'LOAD_CACHING_INFO_RESP', THROW_ERROR: 'THROW_ERROR', SET_DEP_GRAPH: 'SET_DEP_GRAPH', + SET_SERVER_ERROR: 'SET_SERVER_ERROR', } diff --git a/src/reducers/index.js b/src/reducers/index.js index 6ec5b0f..a9b6e0d 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -48,6 +48,7 @@ const defaultState = { visits_required_every_n_days: 0, }, error: undefined, + server_error: false, depGraph: {nodes: [], edges: []}, } @@ -180,6 +181,12 @@ export default (state = defaultState, action) => { depGraph: action.payload } + case ActionTypes.SET_SERVER_ERROR: + return { + ...state, + server_error: action.payload + } + default: return state }