api-platform / admin

A beautiful and fully-featured administration interface builder for hypermedia APIs
https://api-platform.com/docs/admin/
MIT License
484 stars 131 forks source link

Hangs/Crashes/Unresponsiveness after a few sort and/or filtering actions #413

Closed 4c0n closed 2 years ago

4c0n commented 2 years ago

API Platform version(s) affected: 2.6.7

Description
When using filters for filtering or sorting together with Mercure. After a few clicks things get really slow and/or unresponsive. Eventually the eventsource type requests fail and allow for a new action, however the same thing happens quite soon after. It also becomes impossible to refresh the page at this point. However closing a tab/window in the browser resets the problem.

How to reproduce
Go to https://demo.api-platform.com/admin#/books and click the Author header about 7 times to sort the list by author. You should see that the refresh button turns into the loading spinner. Now when you for example sort by a different column a few times it completely hangs and refreshing the page will no longer work.

alanpoulain commented 2 years ago

It seems it's because each time a sorting is done, all SSE streams are created again without closing the previous ones and it saturates the browser. Something needs probably to be changed in https://github.com/api-platform/admin/blob/main/src/ListGuesser.js.

4c0n commented 2 years ago

It seems that subsciptions are managed in the data provider and a reference to the dataprovider seems available from https://github.com/api-platform/admin/blob/main/src/useMercureSubscription.js

I'd say it would probably be a good idea to fix the problem from there. Maybe you or @Shywim have a better idea? There's no documentation on how this is supposed to work, so it's a little hard for me to understand, I'm also by no means an expert on any of this.

However the whole Mercure feature just makes the admin very unusable at this point and the only way to get around it is to just disable it. Which is a shame, because it would be really nice to have.