codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.39k stars 1.9k forks source link

Bug: ErrorException Maximum execution time of 60 seconds exceeded #6371

Closed bossoff closed 2 years ago

bossoff commented 2 years ago

PHP Version

8.0

CodeIgniter4 Version

4.2.3

CodeIgniter4 Installation Method

Composer (as dependency to an existing project)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

MySQL

What happened?

Hi! Please I need some quick explanation on how to fix the error of ErrorException #1 "Maximum execution time of 60 seconds exceeded". I started noticing this error the very time I upgraded my CI Project from the lower version to 4.2.3, I see that anytime I stay longer on the page while my session is not active (CI_ENV = DEVELOPMENT MODE) keep getting the error until I refresh the page. But I got this on my login page the most of time (Something like 419 error in laravel).

For example: let me say I log out from my dashboard account now and the system redirects me back to the login page which is normal then I hibernate my PC for something. This error will pop up.

But I notice are many ways to handle this issue in (LARAVEL) true exception by hardcode. Believe me, have made a lot of research to solve these issues but still get stuck.

Kindly find the attachment below for the proof.

image

image

image

Please Help

Steps to Reproduce

Am Lost

Expected Output

But I notice are many ways to handle this issue in (LARAVEL) true exception by hardcode. Believe me, have made a lot of research to solve these issues but still get stuck.

Anything else?

Please Help

kenjis commented 2 years ago

Why do you show the code to fix Laravel? What is the relation?

HTTP status code 419 is not assigned. https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

Please provide Steps to Reproduce. Minimum code to reproduce the error.

Thank you.

bossoff commented 2 years ago

Ooh so sorry about that.

But to my own point of view, I think CI should name that kind of throw (response) with a status code, then redirect us to a specific page view made for it like 404 and all, or CI should give us the right to manipulate, hardcode within the "app/config/exception".

Thanks

kenjis commented 2 years ago

Your error is "Maximum execution time of 60 seconds exceeded". In my understanding, the Laravel 419 error means CSRF error.

For example: let me say I log out from my dashboard account now and the system redirects me back to the login page which is normal then I hibernate my PC for something. This error will pop up.

Ah, do you say like the following?

  1. you are redirected to the login page
  2. you hibernate your PC
  3. some hours later, you start up your PC and post the login form

And you think the error's cause is CI's CSRF protection.

I don't know the CSRF protection causes your error.

If you don't want to be redirected, please try:

--- a/app/Config/Security.php
+++ b/app/Config/Security.php
@@ -94,7 +94,7 @@ class Security extends BaseConfig
      *
      * @var bool
      */
-    public $redirect = true;
+    public $redirect = false;

     /**
      * --------------------------------------------------------------------------
bossoff commented 2 years ago

Well Laravel assigned status code 419 to many errors Like Session timeout, page expired, page expired csrf e.t.c.

  1. My login page was left open for some hours on the same tab, same browser (Chrome).
  2. Yeah which I did for a purpose
  3. I did not post to log in to the form, this error will just pop up. Until I refresh the page.
  4. My CSRF is working perfectly.

NOTE: What I mean is that any time my authenticate session expires as a user my system will redirect that particular user to the login page, after the user is on the login page, then let's say the user minimizes his/her browser for some hours living the tab open and continue with other things anytime his/her come back to revisit the site on that while the tab is still open, this error of ErrorException #1 will comes up but once the page is refresh everything will get back to normal.

Thanks

seunex17 commented 2 years ago

There are many reasons why CI will throw an excursion timeout error. Let say I have an infinite for each loop and my PHP execution time is 60secs after it elapse I see that error or increase my PHP excursion time.

About the user login related you need to check your really well am not sure if it CI core causing this.

Maybe your conditional check if user is logged is taking too much time or memory to execute. Examine your code again.

bossoff commented 2 years ago

Very well. Firstly my execution time is set to be 300 and I have no logic pass to the login method than to return view. I make use of the "filter" to handle the auth request through the route.

The reason why am still curious about this error is the production level.

Thanks

kenjis commented 2 years ago

This seems not a framework bug, because you are the only person who reports like this in this planet. If so, your app has a problem.

The error occurs in auth.php, so the code is most suspicious.

Anyway we need exact Steps to Reproduce and minimum code to reproduce the error.

bossoff commented 2 years ago

Well if you said so. let me continue with my assignment till I find out what's causing the error.

Thank you for your time.