Skip to content
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

Debugging a failure to load via Turbolinks #24

Open
pat opened this issue Jul 22, 2021 · 4 comments
Open

Debugging a failure to load via Turbolinks #24

pat opened this issue Jul 22, 2021 · 4 comments

Comments

@pat
Copy link

pat commented Jul 22, 2021

Hey folks,

I'm in the midst of updating the Readings codebase to use more modern versions of Node, Webpack, and many of the other dependencies as well. I've gotten things to a point where almost everything is working - the one exception being Roneo/Formalist forms don't load when the page is navigated to via Turbolinks. If I load/refresh that page directly, the form appears without any issues.

I'm at a bit of a loss on how to debug this… is it more likely to be a Formalist issue? Or Roneo? Any suggestions would be wonderful :)

@makenosound
Copy link
Member

My guess is that if you’ve updated Turbolinks then perhaps the event names have changed between versions: https://github.com/icelab/roneo/blob/master/src/index.js#L28-L40

Otherwise I’m not sure — could be a few things. Happy to spend 10 minutes on a call poking through if you’re really stuck, @pat!

@pat
Copy link
Author

pat commented Jul 22, 2021

Thanks Max - Turbolinks hasn't changed (the latest version is still 5.2.0), and those events are still the same according to their docs. I'll have another go tomorrow, but I may very well take you up on that offer of a call!

@pat
Copy link
Author

pat commented Jul 23, 2021

Managed to figure it out! The issue is actually within viewloader, introduced in v2.0.1, is where callViews checks if initialized is set, but destroyViews doesn't unset the flag. So, even though Roneo destroys the views as part of loading the next page via Turbolinks' events, callViews still believes its initialised and callViews does nothing.

I had a quick go at setting the flag to false at the end of destroyViews, but it seems (at least in this app) there's a double call to callViews for some reason (after the destroyViews call) and it's only the second call where the new view data is actually present, but only the first call does anything. So I've downgraded back to viewloader v2.0.0 and it's all happy again - I may try to put together a proper fix if I have the chance.

@makenosound
Copy link
Member

Ah, good spelunking. Viewloader is now essentially superseded by https://github.com/makenosound/defo so perhaps I could upgrade the usage to that sometime (which makes the lifecycle management a lot clearer/magic).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants