action-scheduler icon indicating copy to clipboard operation
action-scheduler copied to clipboard

Add retries to Actions

Open n3f opened this issue 5 years ago • 9 comments

Adds an optional field to the ActionScheduler API for a retry parameter. (For non-recurring actions).

// For example, this tries `do_work` 1 time (if it fails the first time).
as_enqueue_async_action( 'do_work', [], '', 1 );

Exceptions thrown by an Action schedule a new Action (with the same hook and args) on an exponential backoff algorithm.

Tests included.

  • [x] Update the API
  • [x] Update store
    • wpPostStore
      • [x] save_action()
      • [x] fetch_action()
    • DBStore
      • [x] save_action()
      • [x] fetch_action()
  • [x] Implement retries in QueueRunner
  • [x] Update UI
  • [x] Ensure backwards compatibility
  • [x] Add tests

n3f avatar Sep 09 '20 23:09 n3f

Closing/opening to re-trigger travis.

n3f avatar Sep 21 '20 17:09 n3f

Update version / hooks

@n3f We have other PRs in progress that will require a version bump so we will be bumping the version in a separate PR.

rrennick avatar Sep 21 '20 17:09 rrennick

The ability to retry certain actions is a must-have for any queue runner, nice work!

What's the current status on this PR? Anything I can do to help?

vdwijngaert avatar Nov 27 '20 09:11 vdwijngaert

It works as is, but @rrennick has a valid point about the storage. I was hoping to not require schema changes, but that's probably what's needed at this point.

n3f avatar Nov 30 '20 20:11 n3f

@ObliviousHarmony, I wanted to get your thoughts on this and how it could potentially be integrated with WooCommerce Webhooks.

  • Would we need some mechanism for the webhook to interrogate the process to see if there would be a retry (before logging a failed delivery)?
  • Is it OK to throw an Exception to trigger a retry?

n3f avatar Feb 23 '21 07:02 n3f

Any news here? Would love to use this kind of functionality!

michaelrimbach avatar Jun 01 '21 07:06 michaelrimbach

Noodling on this a little, I'm curious why we don't extend support for retries to recurring actions.

On one hand I understand they may not be useful in some cases (perhaps for actions that recur with high frequency) but, hypothetically, what if the service I have sold to my customers is a weekly email: I really want that email to go out, every week, because that's my business offering: and if it doesn't work I'd like it to automatically retry n times. Why wouldn't we allow for that?

Just curious if there are other technical reasons that make it unattractive.

barryhughes avatar Jun 15 '21 20:06 barryhughes

Is this still planned ?

zewelor avatar Jun 15 '22 07:06 zewelor

Webhooks automatically retrying themselves is a must have. Thanks for your effort in this. @n3f

A reviewer (@vedanshujain) commented, but I thnk that n3f didn't read it.

If someone know a bit about it, and acknowledge the comments, this may get resolved. Or is @rrennick the only one that can merge the pull request?

Anyways, thanks!

TIBI4 avatar Aug 24 '22 04:08 TIBI4

Would be useful to see this come to fruition. Even simply having the ability to manually re-run/retry an action would be useful. We have an action that gets scheduled as follow up to receiving a webhook. If the action fails we don't have a good way of setting the same action with the same parameters back up. Ideally, we'd see the failed action, look into the problem, fix it the issue, and run the action again.

JasonTheAdams avatar Dec 08 '22 00:12 JasonTheAdams

Closing, as it doesn't seem like there is an active need for this (and, it would be possible to implement from the parent application via a self-cancelling recurring action, etc).

barryhughes avatar Oct 25 '23 22:10 barryhughes