Open
Description
Django Debug Toolbar: v5.1.0
Settings:
DEBUG_TOOLBAR_CONFIG = {
"UPDATE_ON_FETCH": True,
"ROOT_TAG_EXTRA_ATTRS": "data-turbo-permanent"
}
Using the example project with the above settings as an example, the sidebar will refresh with the Turbo page loads. Between Turbo 8.0.0 Beta 1 and Beta 2 (and all versions after Turbo 8 Beta 2), the sidebar no longer updates .
The History is correctly tracked and you can open the History and switch to any of the page loads, just the sidebar doesn't automatically update to the latest page load.
Activity
matthiask commentedon Mar 21, 2025
We have changed a problem with fetch in 5.1, see #2101
Did it work with django-debug-toolbar 5.0.1? I think we have improved the state of things but of course something else will always break.
I'm cc-ing @karolyi who has debugged the original issue and contributed the fix.
karolyi commentedon Mar 21, 2025
Hey @chrisgrande,
since I don't know that framework (if it is one), I'll need to get you to put together a reproducible example.
Seeing the screencasts, there are errors generated in the console as you click, I want to see what those are.
karolyi commentedon Mar 21, 2025
Btw, as you stated it works with the earlier version of "turbo" (whatever that is), so if the earlier version works with django-debug-toolbar 5.1.0, I am unsure the toolbar is at fault.
chrisgrande commentedon Mar 25, 2025
Hi @karolyi — here is an updated example app:
https://github.com/chrisgrande/django-debug-toolbar/tree/turbo-8
There was already a test page in the example app using Turbo 7.2.4, I created two additional pages, 8b1, and 8b2. You need to hard refresh each versions page to get the new Turbo version loaded.
Looking at the changes between Turbo 8 beta 1 and 2, not sure if this might be causing the issue.
karolyi commentedon Mar 26, 2025
I've checked out your repo today, and all I can see is some weird const redeclaration error that isn't coming from django-debug-toolbar:
Are you sure it is the toolbar to blame here? I see a script tag injected into the page that must be at fault:
chrisgrande commentedon Mar 27, 2025
The injected JS was duplicated from the original Turbo example page in the repo, originally added here.
I have updated my repo removing the increment buttons and that JS from the Turbo 8 pages and have added an example with the current version of Turbo 8.0.13. There shouldn't be any obvious console errors now, however the toolbar doesn't update on the page navigation, with versions b2+.
karolyi commentedon Mar 28, 2025
Do you mean the navigation between the test urls
http://127.0.0.1:8000/turbo-beta2/
andhttp://127.0.0.1:8000/turbo-beta2/2
?For me the toolbar registers the http requests just fine:
karolyi commentedon Mar 28, 2025
Oh wait, you meant the
UPDATE_ON_FETCH
option? I didn't even know about that option, since I don't build single page applications. I'll look into it but can't promise anything.karolyi commentedon Mar 28, 2025
I guess the whole thing comes down to the order of loading javascripts. It seems that turbo grabs the original window.fetch before toolbar.js overrides (rebinds) it, and so toobar's version doesn't even get used on a page load by turbo.
That has nothing to do with my change.
karolyi commentedon Mar 28, 2025
So, yes, upon more investigating (downloaded turbo.js locally and added some debug to before
nativeFetch
, it is what I just pointed out: they grab the original window.fetch before toolbar.js has the opportunity to rebind it.As long as they use that reference, I'm surprised that toolbar can even pick up the http requests at all. I didn't go into the djdt source to see why the latter happens, but the reason for the former is indeed what you've suggested, and thus I think it's outside the scope of this project.