Exception in periodic task stops this task queue
See original GitHub issueName of Issue
Exception in periodic task stops this task queue
- ActionHero Version:
19.1.4
- Node.js Version:
8.11.3
- Operating System:
(Windows 10)
Steps to reproduce your error
To create test-task.js with content:
const {api, Task} = require('actionhero')
exports.SayHello = class SayHello extends Task {
constructor () {
super()
this.name = 'sayHello'
this.description = 'I say hello'
this.frequency = 1000
this.queue = 'low'
this.middleware = []
}
async run () {
api.log("hello",'info');
throw 'exception from SayHello periodic task';
}
}
Steps to fix error
Old snippet in actionhero/initializers/tasks.js:
return {
plugins: plugins,
pluginOptions: pluginOptions,
perform: async function () {
let combinedArgs = [].concat(Array.prototype.slice.call(arguments))
combinedArgs.push(this)
let response = await task.run.apply(task, combinedArgs)
await api.tasks.enqueueRecurrentTask(taskName)
return response
}
}
}
to replace by new:
return {
plugins: plugins,
pluginOptions: pluginOptions,
perform: async function () {
let combinedArgs = [].concat(Array.prototype.slice.call(arguments))
combinedArgs.push(this)
let response = null;
try{
response = await task.run.apply(task, combinedArgs)
} catch (error) {
throw error
}
finally {
await api.tasks.enqueueRecurrentTask(taskName)
}
return response
}
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
task exceptions are not handled for periodic tasks in eager mode
The huey consumer doesn't handle exceptions on tasks if huey is configed to run always_eager=True This results in the worker process/thread ...
Read more >Jenkins stops processing builds in the build queue after an ...
If for some reason, this task fails, this causes the queue to become unresponsive and the jobs eventually stop being run as they...
Read more >Universal exception handler for @Scheduled tasks in Spring ...
Here is an example of setting custom error handler (Spring 2.0.2): @Bean public TaskScheduler taskScheduler() { ConcurrentTaskScheduler ...
Read more >Issues and limitations | Cloud Tasks Documentation
With the exception of tasks scheduled to run in the future, task queues are completely agnostic about execution order. There are no guarantees...
Read more >Guide — huey 2.4.4 documentation
Huey tasks can be cancelled dynamically at runtime. This applies to regular tasks, tasks scheduled to execute in the future, and periodic tasks....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s a good hint that perhaps the option should be on the task itself!
It seems to me that this is an excessive complication. I think that
reEnqueuePeriodicTaskIfException
option in the task will be more than enough.