MiniProfiler / rack-mini-profiler

Profiler for your development and production Ruby rack apps.
MIT License
3.7k stars 402 forks source link

When Turbolinks is enabled rack-mini-profiler makes and ever increasing number of duplicated XHR requests for profiler results #467

Closed jimeh closed 3 years ago

jimeh commented 3 years ago

I believe there's an issue around JavaScript event handlers which register themselves on page load to fetch profiler results from /mini-profiler-resources/results. Each time a Turbolinks link is clicked, it seems to create another results fetcher handler, leading to an ever increasing number of duplicated handlers making identical requests to /mini-profiler-resources/results.

I have a basic proof of concept app:

It's a blank Rails 6 app, two pages with links back and forth between them, and rack-mini-profiler added.

And here's a gif of if too for good measure:

profiler-bug

zokioki commented 3 years ago

Can confirm this is happening on my Turbolinks-enabled app as well (Rails 6.1.0, Turbolinks 5.2.0).

SamSaffron commented 3 years ago

@OsamaSayegh can you investigate?

OsamaSayegh commented 3 years ago

I've opened https://github.com/MiniProfiler/rack-mini-profiler/pull/474 to fix this. Thank you so much @jimeh for the proof of concept, it was really helpful for debugging this issue 👍

SamSaffron commented 3 years ago

@zokioki / @jimeh can you confirm it corrects the issue? If so I will push a new version of the gem out there.

zokioki commented 3 years ago

@SamSaffron Confirming that this does fix the issue in my case - thanks y'all! 👍

jimeh commented 3 years ago

Sorry for my delayed response.

I can confirm it has fixed the issue on my end as well. I've updated the demo Rails app as proof too: https://cryptic-dawn-20880.herokuapp.com/hello/page_a

jimeh commented 3 years ago

@OsamaSayegh thanks for the fix :)