laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.55k stars 11.03k forks source link

Array offset error when using the Concurrency facade #52752

Closed heychazza closed 2 months ago

heychazza commented 2 months ago

Laravel Version

11.23.2

PHP Version

8.3.11

Database Driver & Version

SQLite

Description

The Concurrency facade returns a "Trying to access array offset on null" error, when attempting to use the run method. This error seems to be at $result['successful'] within the ProcessDriver class.

From some testing I've done myself it still seems that Laravel is unable to find the php binary from Herd, as (new PhpExecutableFinder)->find(false) returns false.

Steps To Reproduce

Create a route like the following:

Route::get('/concurrency', function () {
    [$test] = Concurrency::run([
        fn () => DB::table('users')->get(),
    ]);

    return response()->json([
        'test' => $test,
    ]);
});

Laravel will error out at the Concurrency::run line.

crynobone commented 2 months ago

PR #52744 should fix this issue.

heychazza commented 2 months ago

Hey @crynobone, seems the issue still exists (not being able to use Concurrency) when using Laravel Herd.

Latest Herd (just updated), Laravel 11.23.4, PHP 8.3.11

Moved to https://github.com/laravel/framework/issues/52767

CleanShot 2024-09-12 at 5  04 10@2x

brandonaaskov commented 1 month ago

For future travelers, if you're using the latest version of Laravel, the issue isn't Herd. Trying using the fork driver as described here: https://laravel.com/docs/11.x/concurrency#how-it-works

misodrobny commented 2 weeks ago

For future travelers, if you're using the latest version of Laravel, the issue isn't Herd. Trying using the fork driver as described here: https://laravel.com/docs/11.x/concurrency#how-it-works

The problem is fork is only supported in CLI. Do we have a solution without using fork?

misodrobny commented 2 weeks ago

PR #52744 should fix this issue.

I still have this issue in Laravel 11.30.0

crynobone commented 2 weeks ago

@misodrobny please submit new bug report with reproducing code instead of commenting on closed issue.