Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deferred function helper execute the task before the HTTP response has been sent to the user #53055

Closed
saychool opened this issue Oct 8, 2024 · 3 comments

Comments

@saychool
Copy link

saychool commented Oct 8, 2024

Laravel Version

11.26

PHP Version

8.3

Database Driver & Version

Postgresql 16 self hosted on ubuntu 24

Description

upgraded to laravel 11.x from 10.x and still has app/Http/Kernel.php file, adding InvokeDeferredCallbacks to my Kernel.php already like the documentation told (here), but i think the helper didn't work correctly

Steps To Reproduce

Route::get('/testingDefer', function () {
    defer(function () {
        sleep(10);
    });

    return true;
});

just a simple test, i did some complex code before but simple test are enough to reproduce

{8710F3E8-B8EA-43CE-829C-DF59ABD69AAC}

@crynobone
Copy link
Member

Can you provide the web server information?

@saychool
Copy link
Author

saychool commented Oct 8, 2024

Can you provide the web server information?

NGINX using Laravel Herd on my local development, NGINX with Ubuntu 24 on production / staging environment

@timacdonald
Copy link
Member

The web server will need to be using PHP-FPM or Lightspeed for the defer function to run after the HTTP connection has disconnected.

If the required web server functions are not available the deferred functions will simply run after the response is sent to the client but before they are disconnected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants