question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception in periodic task stops this task queue

See original GitHub issue

Name 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:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
evantahlercommented, Jun 10, 2019

That’s a good hint that perhaps the option should be on the task itself!

0reactions
dasagancommented, Jun 10, 2019

add a variable for the number of allowed retries or amount of time it’s allowed to retry until it finally returns the error

It seems to me that this is an excessive complication. I think that reEnqueuePeriodicTaskIfException option in the task will be more than enough.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found