Skip to content

feat: pass args to task onSuccess and onFail callbacks #13269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

slavanossar
Copy link
Contributor

@slavanossar slavanossar commented Jul 25, 2025

What?

Passes the same args provided to a task's shouldRestore function to both the onSuccess & onFail callbacks

Why?

Currently onSuccess and onFail are quite useless without any context, this will allow for a wider range of functionality:

  • Checking if it's the last failure
  • Access to the task input
  • Access to req to allow logging, email notifications, etc.

How?

  1. Created a new TaskCallbackArgs type, which replicates the args of the ShouldRestoreFn type.
  2. Add a TaskCallbackFn type
  3. Update the function calls of both onSuccess and onFail.

Questions

  • I wasn't sure about the typing of input – I can see input: input! being used elsewhere for task errors so I replicated that.
  • Same for taskStatus, I added a type check but I'm not sure if this is the right approach (what would scenario would result in a null value?). Should TaskCallbackArgs['taskStatus'] be typed to allow for null values?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant