Skip to content

Commit 01e6372

Browse files
committed
[ML] Fixing unnecessary deleting job polling (#73087)
1 parent 0a578f7 commit 01e6372

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list_view

x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list_view/jobs_list_view.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,14 @@ export class JobsListView extends Component {
6363
this.showDeleteJobModal = () => {};
6464
this.showStartDatafeedModal = () => {};
6565
this.showCreateWatchFlyout = () => {};
66+
// work around to keep track of whether the component is mounted
67+
// used to block timeouts for results polling
68+
// which can run after unmounting
69+
this._isMounted = false;
6670
}
6771

6872
componentDidMount() {
73+
this._isMounted = true;
6974
this.refreshJobSummaryList(true);
7075

7176
if (this.props.isManagementTable !== true) {
@@ -87,6 +92,7 @@ export class JobsListView extends Component {
8792
if (this.props.isManagementTable === undefined) {
8893
deletingJobsRefreshTimeout = null;
8994
}
95+
this._isMounted = false;
9096
}
9197

9298
openAutoStartDatafeedModal() {
@@ -232,7 +238,7 @@ export class JobsListView extends Component {
232238
};
233239

234240
async refreshJobSummaryList(forceRefresh = false) {
235-
if (forceRefresh === true || this.props.blockRefresh !== true) {
241+
if (this._isMounted && (forceRefresh === true || this.props.blockRefresh !== true)) {
236242
// Set loading to true for jobs_list table for initial job loading
237243
if (this.state.loading === null) {
238244
this.setState({ loading: true });
@@ -283,6 +289,10 @@ export class JobsListView extends Component {
283289
}
284290

285291
async checkDeletingJobTasks(forceRefresh = false) {
292+
if (this._isMounted === false) {
293+
return;
294+
}
295+
286296
const { jobIds: taskJobIds } = await ml.jobs.deletingJobTasks();
287297

288298
const taskListHasChanged =

0 commit comments

Comments
 (0)