hibiken / asynq

Simple, reliable, and efficient distributed task queue in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEATURE REQUEST] [BUG] PostEnqueueFunc -> When Error occur, info is nil and we dont have way to access task

abhi9720 opened this issue · comments

Is your feature request related to a problem? Please describe.

I have created a new periodic task manager and registered a post-enqueue function with it. However, due to some issue such as a task ID conflict, an error occurred and the taskinfo became nil. Now, how to access the task in the post method to determine which task caused the error.

Describe the solution you'd like

  1. Just Like PreEnqueueFunc func(task *Task, opts []Option), If an error occurs, we can pass the task to a function similar to the PreEnqueueFunc func else pass TaskInfo.

Describe alternatives you've considered

Additional context

which task caused the error

Are you talking about an error which is encountered in a task handler?

You can use a asynq.MiddlewareFunc which returns an asynq.Handler. In that you can ProcessTask and see if any error or panic occurs and dump the task id, payload e.t.c.

@kamikazechaser

I am talking about PostEnqueueFunc, when taskId conflict happens, I get an error of task id conflict, but I have no info about which task is in the post-enqueue function.

That is intended behavior, whenever an error occurs anywhere in the "Run" chain a nil value is returned in place of the return type (a pointer), in this case it happens in the Enqueue method. I personally don't see this as a bug but you definitely have less info to work with in the event of an error.

It could make sense to enrich the error messages in the Enqueue method instead. Would that suffice?

@kamikazechaser, ya something like that which help us to get access to error of that task.