0

I have been having this issue on multiple devices, with both Sail and artisan serve:

I have a basic controller like this:

<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    function test($id) {
        if ($id == 1) {
            sleep(45);
        }

        return 'Hello World';
    }
}

with this in my web.php route file:

Route::controller(Controller::class)->group(function () {
    Route::get('/test/{id}', 'test');
});

Then, in Chrome I will go to localhost/test/1 and immediately go to localhost/test/2 in Firefox. In chrome, the tab will sit and wait for 45 seconds before loading as expected. However, Firefox will also wait until the Chrome script finishes before it loads. If you visit localhost/test/2 without visiting the other first, it loads instantly as expected.

What is going on? Why is one script blocking all others, and how do I fix it?

sharf
  • 2,123
  • 4
  • 24
  • 47
  • Maybe because of `sleep()` function – Abdulla Nilam Dec 30 '22 at 05:36
  • @AbdullaNilam I have tried it with a loop just decrementing a large number, in case sleep was causing the issue, same result. Sleep does not cause this issue in vanilla PHP either. – sharf Dec 30 '22 at 14:16

0 Answers0