diff --git a/x-pack/plugins/ml/public/timeseriesexplorer/components/forecasting_modal/forecasting_modal.js b/x-pack/plugins/ml/public/timeseriesexplorer/components/forecasting_modal/forecasting_modal.js index c72efd5c5fa0..2ac92b626728 100644 --- a/x-pack/plugins/ml/public/timeseriesexplorer/components/forecasting_modal/forecasting_modal.js +++ b/x-pack/plugins/ml/public/timeseriesexplorer/components/forecasting_modal/forecasting_modal.js @@ -223,7 +223,14 @@ export const ForecastingModal = injectI18n(class ForecastingModal extends Compon const progress = _.get(resp, ['stats', 'forecast_progress'], previousProgress); const status = _.get(resp, ['stats', 'forecast_status']); - this.setState({ forecastProgress: Math.round(100 * progress) }); + // The requests for forecast stats can get routed to different shards, + // and if these operate at different speeds there is a chance that a + // previous request could arrive later. + // The progress reported by the back-end should never go down, so + // to be on the safe side, only update state if progress has increased. + if (progress > previousProgress) { + this.setState({ forecastProgress: Math.round(100 * progress) }); + } // Display any messages returned in the request stats. let messages = _.get(resp, ['stats', 'forecast_messages'], []); @@ -286,7 +293,12 @@ export const ForecastingModal = injectI18n(class ForecastingModal extends Compon } } else { - previousProgress = progress; + if (progress > previousProgress) { + previousProgress = progress; + } + + // Reset the 'no progress' check value. + noProgressMs = 0; } }