Skip to content

Commit

Permalink
Consider null/undefined returned from executor as success as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Jan 20, 2020
1 parent f0a0385 commit ce26bcc
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions x-pack/legacy/plugins/actions/server/lib/task_runner_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class TaskRunnerFactory {
actionId,
request: fakeRequest,
});

if (executorResult.status === 'error') {
// Task manager error handler only kicks in when an error thrown (at this time)
// So what we have to do is throw when the return status is `error`.
Expand All @@ -99,17 +100,17 @@ export class TaskRunnerFactory {
executorResult.data,
executorResult.retry == null ? false : executorResult.retry
);
} else if (executorResult.status === 'ok') {
// Cleanup action_task_params object now that we're done with it
try {
const savedObjectsClient = getScopedSavedObjectsClient(fakeRequest);
await savedObjectsClient.delete('action_task_params', actionTaskParamsId);
} catch (e) {
// Log error only, we shouldn't fail the task because of an error here (if ever there's retry logic)
logger.error(
`Failed to cleanup action_task_params object [id="${actionTaskParamsId}"]: ${e.message}`
);
}
}

// Cleanup action_task_params object now that we're done with it
try {
const savedObjectsClient = getScopedSavedObjectsClient(fakeRequest);
await savedObjectsClient.delete('action_task_params', actionTaskParamsId);
} catch (e) {
// Log error only, we shouldn't fail the task because of an error here (if ever there's retry logic)
logger.error(
`Failed to cleanup action_task_params object [id="${actionTaskParamsId}"]: ${e.message}`
);
}
},
};
Expand Down

0 comments on commit ce26bcc

Please sign in to comment.