Skip to content

Failed Job in Chained Batch, doesn't call Finally closure #39243

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

Closed
wit3 opened this issue Oct 18, 2021 · 2 comments
Closed

Failed Job in Chained Batch, doesn't call Finally closure #39243

wit3 opened this issue Oct 18, 2021 · 2 comments

Comments

@wit3
Copy link
Contributor

wit3 commented Oct 18, 2021

  • Laravel Version: 8.64.0
  • PHP Version: 8.0.10
  • Database Driver & Version: PostgreSQL, 10.11

Description:

Hi, if i distpach a simple chained batch like this : chains-within-batches

Bus::batch([
    [
        new ReleasePodcast(1),
        new SendPodcastReleaseNotification(1),
    ],
    [
        new ReleasePodcast(2),
        new SendPodcastReleaseNotification(2),
    ],
])
->finally(function (Batch $batch) {
    // The batch has finished executing...
})
->then(function (Batch $batch) {
    // ...
})->dispatch();

If any of thes chained job fail, the closure defined doesn't trigger, it's a bug?

Steps To Reproduce:

@driesvints
Copy link
Member

See #36076

@taylorotwell
Copy link
Member

This is a slightly different issue than #36076

I can see the reasoning behind the current behavior to some extent - the "finally" callback executes when all of the jobs in the batch have fun exactly once (success or failure - doesn't matter)... in the case of your chain, the jobs after the failing job have not executed at all, so finally is never firing. It isn't firing because "pending jobs" - "failed jobs" does not equal 0.

CleanShot 2021-11-03 at 10 38 58@2x

This is because when you add a chain to a batch we increment pending jobs for the number of jobs in the chain.

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

No branches or pull requests

3 participants