You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This function is called after the `run` function is executed, regardless of whether the run was successful or not. It's useful for cleaning up resources, logging, or other side effects.
Errors thrown in the `cleanup` function will fail the attempt.
180
+
</Info>
181
+
174
182
### `middleware` function
175
183
176
184
This function is called before the `run` function, it allows you to wrap the run function with custom code.
177
185
186
+
<Info>
187
+
An error thrown in `middleware` is just like an uncaught error in the run function: it will propagate through to `handleError()` and then will fail the attempt (causing a retry).
188
+
</Info>
189
+
178
190
### `onStart` function
179
191
180
192
When a task run starts, the `onStart` function is called. It's useful for sending notifications, logging, and other side effects. This function will only be called one per run (not per retry). If you want to run code before each retry, use the `init` function.
Errors thrown in the `onStart` function are ignored.
221
+
</Info>
222
+
207
223
### `onSuccess` function
208
224
209
225
When a task run succeeds, the `onSuccess` function is called. It's useful for sending notifications, logging, syncing state to your database, or other side effects.
Errors thrown in the `onSuccess` function are ignored.
254
+
</Info>
255
+
236
256
### `onFailure` function
237
257
238
258
When a task run fails, the `onFailure` function is called. It's useful for sending notifications, logging, or other side effects. It will only be executed once the task run has exhausted all its retries.
Errors thrown in the `onFailure` function are ignored.
287
+
</Info>
288
+
265
289
### `handleError` functions
266
290
267
291
You can define a function that will be called when an error is thrown in the `run` function, that allows you to control how the error is handled and whether the task should be retried.
268
292
269
293
Read more about `handleError` in our [Errors and Retrying guide](/errors-retrying).
270
294
295
+
<Info>
296
+
Uncaught errors will throw a special internal error of the type `HANDLE_ERROR_ERROR`.
0 commit comments