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
When attempting to process tasks concurrently by chunking an array of data using ConcurrencyManager, you will get an exception thrown. the tasks are not executed as expected, and the exception prevents the process from completing.
Expected Behaviour :
Given an array of data chunked and processed concurrently, the tasks should execute without errors and return the expected results.
Laravel\SerializableClosure\SerializableClosure::__construct(): Argument #1 ($closure) must be of type Closure, array given, called in /vendor/laravel/framework/src/Illuminate/Concurrency/ProcessDriver.php on line 36.
Behaviour Summary :
the behavior varies depending on the concurrency driver used (process or sync) and how tasks are defined.
The results are summarized in the following table :
Task\Driver
Process
Sync
Closures
❌ Throws Exception
✅ Works
Direct Values
❌ Throws Exception
❌ Throws Exception
Steps To Reproduce
Set the default concurrency driver in config/concurrency.php to process (or sync for testing the ‘Direct Values’ case) :
return [
'default' => 'process', // or 'sync' for 'Direct Values' case
];
Laravel\SerializableClosure\SerializableClosure::__construct(): Argument #1 ($closure) must be of type Closure, array given, called in /vendor/laravel/framework/src/Illuminate/Concurrency/ProcessDriver.php on line 36
Using sync driver :
First array member is not a valid class name or object
at vendor/laravel/framework/src/Illuminate/Concurrency/SyncDriver.php:20
16▕ */
17▕ public function run(Closure|array $tasks): array
18▕ {
19▕ return collect(Arr::wrap($tasks))->map(
➜ 20▕ fn ($task) => $task()
21▕ )->all();
22▕ }
The text was updated successfully, but these errors were encountered:
Laravel Version
11.33.2
PHP Version
8.2
Database Driver & Version
MySQL 8.3.0
Description
When attempting to process tasks concurrently by chunking an array of data using
ConcurrencyManager
, you will get an exception thrown. the tasks are not executed as expected, and the exception prevents the process from completing.Expected Behaviour :
Given an array of data chunked and processed concurrently, the tasks should execute without errors and return the expected results.
Actual Behaviour :
When executing the above code, exceptions occur in the following scenarios.
An exception is thrown when attempting to process closures that return the chunked data.
When trying to process tasks by passing direct values instead of closures:
An exception is thrown:
Behaviour Summary :
the behavior varies depending on the concurrency driver used
(process or sync)
and how tasks are defined.The results are summarized in the following table :
Steps To Reproduce
config/concurrency.php
to process(or sync for testing the ‘Direct Values’ case)
:Result :
Result :
Using
process
driver :Using
sync
driver :The text was updated successfully, but these errors were encountered: