cms icon indicating copy to clipboard operation
cms copied to clipboard

Thousands of events created on collection request when using Telescope

Open elijahworkz opened this issue 2 years ago • 12 comments

Bug description

Request to Pages collection takes long time and thousands of events generated

I initially noticed this issue after upgrading my install to Statamic 3.3.3 and Laravel 9. Any collection with more than a few pages would take a really long time to load. 2022-04-05_15-36 TTFB - is how long I see the request took in the Telescope, but the page remains in loading state until the Content Download finishes.

In Telescope same request shows thousands logs, events, cache and redis requests 2022-04-05_15-40

I am using custom Eloquent driver and wasn't sure if it's connected to that in any way so I have installed a completely fresh version of Statamic and I can see same sort of thing happening with events there. (I didn't add any content, created any blueprints or changed statamic in any way other than install telescope)

How to reproduce

Install fresh copy of statamic as per documentation statamic create $project. Add telescope - composer require laravel/telescope (telescope requires database but I haven't changed any statamic settings)

Open Control Panel and Collections -> Pages

in DevTools you can see the time it takes to load this page with just one page 2022-04-05_15-45

in Telescope -> Requests - you can see the number for events that one request generated 2022-04-05_15-46

Logs

No response

Versions

Statamic 3.3.4 Solo Laravel 9.6.0 PHP 8.1.3 No addons installed

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

No response

Additional details

No response

elijahworkz avatar Apr 05 '22 12:04 elijahworkz

I am using custom Eloquent driver

Your own? Or https://github.com/statamic/eloquent-driver ?

jasonvarga avatar Apr 05 '22 13:04 jasonvarga

@jasonvarga it's basically the same with small modifications for our own needs (we're using multiple models) - but the issue with events is replicated on a clean statamic install without eloquent-driver.

elijahworkz avatar Apr 05 '22 14:04 elijahworkz

Thanks for the excellent write-up, @elijahworkz . I checked my own Telescope logs to see if the behavior was the same and indeed it was. In a collection with only a couple dozen entries, the request to load the index was generating 14156 events.

theutz avatar Apr 05 '22 14:04 theutz

That's a lot. 😬 I'll dive into this soon!

jasonvarga avatar Apr 05 '22 14:04 jasonvarga

I have the same issue as @elijahworkz with Statamic 3.3.4 and Laravel 9.0 I installed new project using statamic create $project and installed telescope nothing more.

Page list request is taking long time as well. pages

In telescope request looks like: request details events

shpakylia avatar Apr 05 '22 15:04 shpakylia

Thanks, there's enough info here. 🤘

jasonvarga avatar Apr 05 '22 16:04 jasonvarga

Okay so I have enabled Laravel Debugbar and turned on the events collector. I load a collection, and see the number of events are reasonable.

Install Telescope, refresh, and the number of events in debugbar skyrocket.

Remove telescope, the events drop back down.

So, it's an issue with Telescope.

We can address it, but just letting you know that it's not going to be happening without Telescope running, if you need a workaround. Even just adding TELESCOPE_ENABLED=false to your .env should result in the number of events and load times to drop.

jasonvarga avatar Apr 06 '22 20:04 jasonvarga

@jasonvarga I can confirm that adding TELESCOPE_ENABLED=false solves the load speed issue (is it normal that I didn't have to run php artisan config:clear - it seems it was automatically picked up?!)

Thanks! We can use it as temporary solution, but it would be great to have statamic 3.3.* play nicely with telescope

elijahworkz avatar Apr 07 '22 06:04 elijahworkz

Laravel Telescope is a standard so it would be great for Statamic to work with. Additionally, it worked in previous versions.

jtomek avatar Apr 07 '22 07:04 jtomek

Thanks, @jasonvarga ! That solved it for me, too! I guess that probably closes #5561 , then.

theutz avatar Apr 07 '22 11:04 theutz

Laravel Telescope is a standard so it would be great for Statamic to work with. Additionally, it worked in previous versions.

Absolutely. I'm just suggesting a workaround.

jasonvarga avatar Apr 07 '22 13:04 jasonvarga

Any updates on this issue? I've just updated to the latest version of statamic (3.3.16) and the issue is still there - with Telescope enabled it takes a long time to load any collection index page. As soon as I disable telescope - it loads very fast again.

elijahworkz avatar Jun 22 '22 07:06 elijahworkz

We are experiencing this issue as well. Some pages, especially pages that render collection listings (ie Blog) are returning a 504 error.

dniccum avatar Feb 22 '23 20:02 dniccum

I've found a "sort of fix". Currently having the same issue on my site. The solution is not perfect but worked for me. Instead of disabling Telescope. Go into the telescope config, and disable event, and gate watching. The speed has now dramatically increased, and I've still got the most important logging with Telescope.

config/telescope.php image

JesperFiltenborg avatar Feb 24 '23 14:02 JesperFiltenborg

Thanks @JesperFiltenborg, unfortunately the main reason why I installed this package was for the event/queue watcher. Overall, this does seem promising.

dniccum avatar Mar 01 '23 18:03 dniccum

This is the first time somebody deleted my comment on GitHub.

It was a polite and relevant feedback from a customer of two years who finds it difficult that such issues still exist.

It is odd that the removal of my comment is the first reaction from Statamic regarding this issue.

Wouldn’t it be more appropriate to address the issues that’s been existing for almost a year?

jtomek avatar Mar 02 '23 08:03 jtomek

@jtomek I feel you. I've experienced frustrations around these kinds of issues, too.

But, to be fair, this is the case with nearly every software product. And, issues arising from integration with third-party tools like Laravel Telescope—while important—I could see being lower priority than core upgrades or improvements.

So, while I'm not sure deleting your comment was fair, as a neutral observer, I felt like your post might've sounded more hostile and unreasonable than you were thinking it was. At least in a GitHub issue thread.

I think your thoughts would be totally appropriate in a blog post or forum post, though. It's useful feedback that I'd hope the Statamic team is taking to heart, even if they don't have the resources to address these specific problems currently.

theutz avatar Mar 02 '23 08:03 theutz

@jtomek wow - I didn't realize it's been almost a year since I opened this issue....

Since then we developed our own admin system :) (nothing against statamic - its great for what it does but it required too many modifications to fit our needs anyways and waiting on fixes... well, it seemed simpler to create something custom fit... )

So, while the issue is no longer relevant to me - it might be helpful for others...

elijahworkz avatar Mar 02 '23 08:03 elijahworkz

I don't think that comment should have been deleted, FWIW. Feedback is fine, even if negative. It didn't seem overly hostile to me.

(For context, since it was deleted, the comment said something about some other platform they switched to.)

jasonvarga avatar Mar 02 '23 16:03 jasonvarga

I just ran into this exact issue with two Statamic 4.42.0 projects. Both projects have Telescope installed. The Pages tree wouldn't load when I added a Linkfield to the homepage and added a link to any entry in the same tree.

As @JesperFiltenborg mentioned, disabling the event and gate watchers "fixed" this issue.

sstottelaar avatar Dec 22 '23 11:12 sstottelaar