-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing support for HotWire Turbo Drive, successor of turbolinks #482
Comments
I tried replacing turbolinks with turbo in includes.js but it is not working. I don't understand how it is supposed to work. As far as I understand the implementation, this is what happens when a turbolink visit happens:
Over the time, MiniProfiler is initialized many times. I believe that it should be marked with |
My experiments now involved initialization in rails: module RackTurboExtension
def get_profile_script(*args, **kargs)
super(*args, **kargs).gsub('></script>', ' data-turbo-permanent="true"></script>')
end
end
module Rack
class MiniProfiler
prepend RackTurboExtension
end
end and in javascript: document.addEventListener("turbo:before-visit", e => {
window.MiniProfilerContainer = document.querySelector('body > .profiler-results')
if(!e.defaultPrevented) window.MiniProfiler.pageTransition()
})
document.addEventListener("turbo:load", e => {
if(window.MiniProfilerContainer) {
document.body.appendChild(window.MiniProfilerContainer)
}
}) |
Bonjour Mildred, Have you tried putting the code into the actual source code as a PR? both look pretty straight forwards (though to be honest I'm more of a back end developer than a front end one) |
Hi, #498 works wonderfully for Turbo Drive but there's still the case of using Turbo Streams and maybe Turbo Frames. When you respond with a stream the profiler will auto-increment the response times. For example it will say 10ms for the first request, 20ms for the 2nd, 30ms for the third, etc. and only gets "fixed" if you manually do a hard reload. You can test this by submitting a form and responding with a stream in your controller. This makes it hard to tell what the true response time is for a stream response which in a Rails 7 app could be every single form submission. |
I think there is something missing still. I tried adding to a brand new app (which uses hotwire/turbo by default), added a few scaffolds. It seems that the profiler goes missing after the first click (ie when using turbo), but comes back when you do a reload. I see this place where hotwire support is detected, but I haven't been able to trace where |
There is a race condition between |
When my turbo drive page reloads, the profiler information is removed. This did not happen when I was using turbolinks.
Most things should work the same, just replace
turbolinks
byturbo
.The text was updated successfully, but these errors were encountered: