Skip to content

Closure in job chain is not called if preceded by job batch #106

Open
@eldair

Description

@eldair

Laravel Version

11.11.1

PHP Version

8.3.8

Database Driver & Version

No response

Description

Closure in job Bus::chain is not called if it is after Bus::batch - exception is thrown but there is nothing in failed jobs.
Call to undefined method Closure::getClosure() {"exception":"[object] (Error(code: 0): Call to undefined method Closure::getClosure() at /home/eldair/code/bus_chain_test/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedClosure.php:107)

Steps To Reproduce

Batch setup

$batch = [];
for ($i=0; $i < 5; $i++) {
    $batch[] = new BatchJob($i + 1);
}

This will throw the exception and the closure will not be called

Bus::chain([
    new ChainedJob,
    Bus::batch($batch),
    function () {
        logger('after batch');
    }
])->dispatch();

This works fine

Bus::chain([
    new ChainedJob,
    Bus::batch($batch),
    new ChainedJob,
    function () {
        logger('after batch');
    }
])->dispatch();

Here is the reproduction repo https://github.com/eldair/bus_chain_test/tree/main, nothing was added except two jobs and console command to call the code above.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions