[GH-ISSUE #782] [FEATURE REQUEST] Ability to modify a task's Payload in middleware #2404

Open
opened 2026-03-15 20:22:44 +03:00 by kerem · 0 comments
Owner

Originally created by @agorman on GitHub (Nov 13, 2023).
Original GitHub issue: https://github.com/hibiken/asynq/issues/782

Originally assigned to: @hibiken on GitHub.

Is your feature request related to a problem? Please describe.
I have a few different use cases where it would be nice to be able to change a tasks payload inside middleware.

Describe the solution you'd like
I'd like a way to change the payload but I haven't found a way to do that without causing other side effects.

Describe alternatives you've considered
I've tried creating a new task using the NewTask method inside the middleware and passing that to the next handler's ProcessTask method. This seems to work okay but I'm not sure if all options are preserved. It also causes the task to lose it's ResultWriter which I'd like to be able to use.

Originally created by @agorman on GitHub (Nov 13, 2023). Original GitHub issue: https://github.com/hibiken/asynq/issues/782 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** I have a few different use cases where it would be nice to be able to change a tasks payload inside middleware. **Describe the solution you'd like** I'd like a way to change the payload but I haven't found a way to do that without causing other side effects. **Describe alternatives you've considered** I've tried creating a new task using the `NewTask` method inside the middleware and passing that to the next handler's `ProcessTask` method. This seems to work okay but I'm not sure if all options are preserved. It also causes the task to lose it's `ResultWriter` which I'd like to be able to use.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#2404
No description provided.