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 using Laravel’s Concurrency::run() feature, the process crashes with Trying to access array offset on null in ProcessDriver.php if a closure contains echo or print. This happens because child processes communicate back to the parent via JSON, and printing to STDOUT corrupts the expected JSON payload, causing $result to become null. Instead of crashing, Laravel should either gracefully handle extra output, redirect it, or clearly document that closures should not use direct output and should return values or use logging instead. Please take a look at this critical architectural flaw.
Steps To Reproduce
`<?php
use Illuminate\Support\Facades\Concurrency;
use Library\Defer\Parallel;
at vendor\laravel\framework\src\Illuminate\Concurrency\ProcessDriver.php:51
47▕ }
48▕
49▕ $result = json_decode($result->output(), true);
50▕
➜ 51▕ if (! $result['successful']) {
52▕ throw new $result['exception'](
53▕ ...(! empty(array_filter($result['parameters']))
54▕ ? $result['parameters']
55▕ : [$result['message']])
1 vendor\laravel\framework\src\Illuminate\Concurrency\ProcessDriver.php:51
Illuminate\Foundation\Bootstrap\HandleExceptions::{closure:Illuminate\Foundation\Bootstrap\HandleExceptions::forwardsTo():257}("Trying to access array offset on null", "C:\Laravel\test-herd\vendor\laravel\framework\src\Illuminate\Concurrency\ProcessDriver.php")
This discussion was converted from issue #57074 on September 17, 2025 07:11.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
12.28.1
PHP Version
8.4.5
Database Driver & Version
No response
Description
When using Laravel’s Concurrency::run() feature, the process crashes with Trying to access array offset on null in ProcessDriver.php if a closure contains echo or print. This happens because child processes communicate back to the parent via JSON, and printing to STDOUT corrupts the expected JSON payload, causing $result to become null. Instead of crashing, Laravel should either gracefully handle extra output, redirect it, or clearly document that closures should not use direct output and should return values or use logging instead. Please take a look at this critical architectural flaw.
Steps To Reproduce
`<?php
use Illuminate\Support\Facades\Concurrency;
use Library\Defer\Parallel;
require "vendor/autoload.php";
$app = require "bootstrap/app.php";
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();
$start1 = microtime(true);
Concurrency::run([
function () {
sleep(1);
echo "Task 1 done";
},
function () {
sleep(2);
echo "Task 2 done";
},
function () {
sleep(3);
echo "Task 3 done";
},
]);
$end1 = microtime(true);
echo 'Concurrency time: ' . ($end1 - $start1) . " seconds\n";
`
`C:\Laravel\test-herd>php test.php
ErrorException
Trying to access array offset on null
at vendor\laravel\framework\src\Illuminate\Concurrency\ProcessDriver.php:51
47▕ }
48▕
49▕ $result = json_decode($result->output(), true);
50▕
➜ 51▕ if (! $result['successful']) {
52▕ throw new $result['exception'](
53▕ ...(! empty(array_filter($result['parameters']))
54▕ ? $result['parameters']
55▕ : [$result['message']])
1 vendor\laravel\framework\src\Illuminate\Concurrency\ProcessDriver.php:51
Illuminate\Foundation\Bootstrap\HandleExceptions::{closure:Illuminate\Foundation\Bootstrap\HandleExceptions::forwardsTo():257}("Trying to access array offset on null", "C:\Laravel\test-herd\vendor\laravel\framework\src\Illuminate\Concurrency\ProcessDriver.php")
2 vendor\laravel\framework\src\Illuminate\Collections\Arr.php:803
Illuminate\Concurrency\ProcessDriver::{closure:Illuminate\Concurrency\ProcessDriver::run():44}()
`
Beta Was this translation helpful? Give feedback.
All reactions