halilcosdu/laravel-slower

[Bug]: Loop when slow logs entries creation are slow too

Closed this issue · 1 comments

What happened?

Sometimes, if the slow logs entries creation is slow (below threshold), it enters an infinite loop saving the slow log entry of the previous slow log entry saving, and again in a recursive infinite loop that hangs the execution.

How to reproduce the bug

Lower the SLOWER_THRESHOLD to 100

Package Version

1.0.5

PHP Version

8.2.0

Laravel Version

11

Which operating systems does with happen with?

Linux

Notes

The problem can be fixed skipping the events which sql contains the slow_logs table name, for example, inserting the following code in https://github.com/halilcosdu/laravel-slower/blob/main/src/SlowerServiceProvider.php#L72

// Skip logging if the query is related to the slow log table
if (Str::contains($event->sql, [(new $model)->getTable()])) {
    return;
}

Thank you for the report. The issue should be fixed now.