Laravel Pulse Crashes with Large SQL Queries

If you’re in the Laravel Ecosystem, You’ve probably heard of Laravel Pulse by now.

Pulse delivers at-a-glance insights into your application’s performance and usage. Track down bottlenecks like slow jobs and endpoints, find your most active users, and more.

From pulse.laravel.com

Exciting right? but when I started using Laravel Pulse on one of my projects, I noticed my browser was crashing after a few seconds of loading the dashboard, after a bit of digging into it, it looked like the root cause of my problem was a very long query.

I ran a scheduled task that performed a select with a large payload of IDs, unfortunately loading this query and showing it in the Slow Queries cart was resulting a crash.

However, fortunately, the fix for this is pretty easy, even tho it is not mentioned in the documentation.

To prevent this we should add an environment variable to our .env file which instructs pulse what should be the max slow query length.

For example, if you want to limit this query to 300 characters, you can add the following in your .env file:

PULSE_SLOW_QUERIES_MAX_QUERY_LENGTH=300

Now this environment variable is not about what is loaded in the dashboard, it is about what is recorded by pulse, this means you might have to wait until the timeframe of the previous logs is over.

I hope sharing this helps some of the folks out there who might be having the same issue with Laravel Pulse.

Leave a Reply