herd-community icon indicating copy to clipboard operation
herd-community copied to clipboard

Timeout after 10 seconds even though php settings are set to 30 seconds [Bug]:

Open metadeck opened this issue 1 year ago • 6 comments

Platform

macOS

Operating system version

macOS Sonoma 14.4.1

System architecture

ARM64 (M1, M2, etc)

Herd Version

1.6.0 Build: 24

PHP Version

8.1.26

Bug description

When working on a site that has to send requests to a slow MS Dynamics site I am getting a timeout while the request is in progress.

The error message is Maximum execution time of 30 seconds exceeded but I have timed it and it times out at 10 seconds every time.

This was working fine on valet so I'm unsure what the issue is.

Flare stack trace attached is here -> https://flareapp.io/share/dPbarwXm

Steps to reproduce

Default installation of Laravel Herd. Run a long running cURL request that exceeds 10 seconds.

Relevant log output

php.ini max_execution_time = 30

metadeck avatar Apr 17 '24 08:04 metadeck

Do you see the correct max_execution_time when you run phpinfo(); in a route?

mpociot avatar Apr 18 '24 07:04 mpociot

i can confirm this. i have same hardware, using php 8.2 changed the php.ini for php 8.2 and added below config

max_execution_time=180
max_input_time=180
memory_limit=256M
post_max_size=20M
upload_max_filesize=20M

when i check using phpinfo(); values as below

max_execution_time=30
max_input_time=-1
memory_limit=128M
post_max_size=8M
upload_max_filesize=2M

I have tried herd restart etc but changes are not applied.

rabiibrahimi avatar Apr 19 '24 21:04 rabiibrahimi

I am having the same problem. When I adjust the memory_limit setting via the UI to -1 I see that it is adjusted in the php.ini file. Through popinfo(); I see the default unadjusted values in the browser. So it is not being implemented. This applies to the CLI version. I have to run this for example like: herd php -d memory_limit=-1 ./vendor/bin/drush cr.

dwabuu avatar Apr 23 '24 08:04 dwabuu

@mpociot Sorry its taken so long to get back.

Inside a controller function I have logged out the phpinfo. It is showing the correct value, I updated this to 60 seconds to test. phpinfo() shows 60 seconds but it still times out after 10 seconds with the message Maximum execution time of 60 seconds exceeded

Screenshot attached Screenshot 2024-05-02 at 16 52 14

metadeck avatar May 02 '24 15:05 metadeck

I can confirm this. It's been there quite some time. Hopefully someone could pinpoint this. I'm subscribing to the thread...

edwinheij avatar May 11 '24 08:05 edwinheij

I am having the same issue that @metadeck reported at the beginning.

image image image

Here, you can see the request returning the max execution error and the time shown by the dev tools.

eliurkis avatar May 15 '24 23:05 eliurkis

Anyone had a solution?

njugunamwangi avatar May 27 '24 13:05 njugunamwangi

Nothing yet. I've combed through all the php config files and cannot find any references to 10 seconds. The weird thing is that it errors with the correct timeout value but always after 10 seconds.

@mpociot is there anything in the Herd core than manually fires a timeout?

metadeck avatar May 27 '24 14:05 metadeck

This is really odd. Can you simply reproduce this by adding a sleep(15) to your code?

mpociot avatar May 27 '24 14:05 mpociot

Now it's even more weird:

Herd 1.6.1:

<?php
print('max_execution_time: ' . ini_get('max_execution_time') . PHP_EOL);
$seconds = 59;
sleep($seconds);
echo 'Done after '.$seconds.' seconds';
exit;

Results in: max_execution_time: 30 Done after 59 seconds with $seconds set to 60 the page does time out with the 504 Gateway Time-out nginx failure. This is my phpinfo: image Then only thing in the phpinfo which is set to 60 is the default_socket_timeout. Don't know if that has to do something with it? image

edwinheij avatar May 28 '24 07:05 edwinheij

I'm facing the same problem. But weirder!

php -i | grep max_execution_time max_execution_time => 0 => 0

biplobice avatar May 28 '24 12:05 biplobice

@mpociot I've added in a sleep call of 20 seconds on my home page and my site loads no problem after the sleep function returns. It looks like the duration of sleep is ignored by max_execution_time. https://www.php.net/manual/en/function.set-time-limit.php#72167

metadeck avatar May 28 '24 13:05 metadeck

I also encountered this issue. I searched through all discussions, but couldn't solve it. So, I reduced the number of sites, and the problem disappeared. I hope this helps others think through the issue.

zhi8617 avatar Jun 01 '24 06:06 zhi8617

Can someone provide a piece of code where I can successfully reproduce this? I'm unable to force this error with sleep I'm afraid

mpociot avatar Jun 01 '24 08:06 mpociot

My hardware is a Mac Mini M1, and the Laravel version is 11.

Recently, I've been frequently encountering timeout errors with approximately an 80% chance. As a result, I have to look for a solution, even for the simplest "hello world" output.

zhi8617 avatar Jun 02 '24 14:06 zhi8617

Is there a way for you to always reproduce this?

mpociot avatar Jun 02 '24 14:06 mpociot

This happens sporadically for me as well, it seems to happen on a large Statamic site I have, but I'm not sure exactly what is causing this exactly to reproduce it.

Here is a flare of the error when its thrown: https://flareapp.io/share/W7zaoKbP

DanielDarrenJones avatar Jun 12 '24 19:06 DanielDarrenJones

I have also experienced this issue, it doesn't happen often, but enough to be quite frustrating.

It mainly happens when running npm run dev in my Laravel app and having multiple windows open with the same application if that's of any help?

It always dies on a redis or database connection.

gainlinejono avatar Jun 16 '24 16:06 gainlinejono

This also happens for me every now and then, timeout after <30s with the default timeout of 30s

SanderMuller avatar Jun 17 '24 08:06 SanderMuller

@mpociot this thread may be of interest to you. Looks like a fix was merged for 8.1, 8.2, 8.3 not too long ago.

https://github.com/php/php-src/issues/12814

gainlinejono avatar Jun 17 '24 08:06 gainlinejono

Ohhh interesting! So this should be fixed when you update PHP 8.2 and 8.3 I'll add this patch to 8.1 as well (as this one is no longer maintained)

mpociot avatar Jun 17 '24 08:06 mpociot

I am running PHP 8.3.8, which PHP 8.3 version should have the patch?

SanderMuller avatar Jun 17 '24 09:06 SanderMuller

Although it was merged in I don't see it in the release notes

gainlinejono avatar Jun 17 '24 09:06 gainlinejono

I've downloaded the latest Herd (1.7.1) along with updating all PHP versions (using php 8.3.8) but still facing the same timeout issue.

Has anyone been able to run this successfully after updating PHP?

metadeck avatar Jun 17 '24 14:06 metadeck

I was getting Maximum execution time of 30 seconds exceeded today after about 2 seconds.

PHP Version: 8.3.8
Herd: 1.7.1 (38) Mac

Switching PHP Version of the Site down to 8.2 fixed it. After Switching back to Version 8.3.8 is still worked.

paul-hph avatar Jun 26 '24 13:06 paul-hph

https://github.com/php/php-src/pull/13567#issuecomment-2191949833

According to this it's been patched in 8.3.9 and 8.2.21 - currently release candidates so it may not have made it through to the Herd PHP versions yet.

@mpociot does this need reopening until it's fixed or tagging in another way as it's still an open issue.

gainlinejono avatar Jun 26 '24 15:06 gainlinejono

My workaround at the minute is adding this to any long running functions or set at a more global level.

// set the max execution time if we are on local environment
if (app()->environment('local')) {
    ini_set('max_execution_time', 300);
}

It's not ideal but patches the issue.

metadeck avatar Jun 27 '24 12:06 metadeck

8.3.9 is now out, i've had the issue after updating but then restarted Herd and been ok since.

gainlinejono avatar Jul 10 '24 08:07 gainlinejono

Also fail on my local environment, solution provided by @metadeck works. Thanks

arnaudlidz avatar Sep 26 '24 16:09 arnaudlidz

@mpociot I don't think this is fixed, I'm on PHP 8.3.12 and on Herd 1.11.0 and I set max_execution_time=180 in php.ini of herd php83 but no effect even after restarting services

SagarNaliyapara avatar Oct 10 '24 08:10 SagarNaliyapara