Skip to content

Commit

Permalink
TaskManager tasks scheduled without attempting to run (#62078)
Browse files Browse the repository at this point in the history
* TaskManager tasks scheduled without attempting to run

* Removing unused import

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
kobelb and elasticmachine committed Apr 10, 2020
1 parent fbd15ec commit cc85573
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions x-pack/plugins/task_manager/server/task_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { filter } from 'rxjs/operators';
import { performance } from 'perf_hooks';

import { pipe } from 'fp-ts/lib/pipeable';
import { Option, none, some, map as mapOptional } from 'fp-ts/lib/Option';
import { Option, some, map as mapOptional } from 'fp-ts/lib/Option';
import {
SavedObjectsSerializer,
IScopedClusterClient,
Expand Down Expand Up @@ -156,8 +156,8 @@ export class TaskManager {
this.events$.next(event);
};

private attemptToRun(task: Option<string> = none) {
this.claimRequests$.next(task);
private attemptToRun(task: string) {
this.claimRequests$.next(some(task));
}

private createTaskRunnerForTask = (instance: ConcreteTaskInstance) => {
Expand Down Expand Up @@ -280,9 +280,7 @@ export class TaskManager {
...options,
taskInstance: ensureDeprecatedFieldsAreCorrected(taskInstance, this.logger),
});
const result = await this.store.schedule(modifiedTask);
this.attemptToRun();
return result;
return await this.store.schedule(modifiedTask);
}

/**
Expand All @@ -298,7 +296,7 @@ export class TaskManager {
.then(resolve)
.catch(reject);

this.attemptToRun(some(taskId));
this.attemptToRun(taskId);
});
}

Expand Down

0 comments on commit cc85573

Please sign in to comment.