locomotivecms / engine

A platform to create, publish and edit sites
http://www.locomotivecms.com
Other
2.32k stars 625 forks source link

Stuck waiting for preview pane to load #1371

Closed dyerc closed 3 years ago

dyerc commented 3 years ago

There were no JS errors logged in the console and I could see by inspecting the iframe that the page had in fact correctly loaded behind the scenes.

After debugging various things, what caused the issue for me was the "Redirect to first domain" setting. I wasn't accessing the engine at the URL of the site I was editing. The new JS editor must not be able to handle this type of event loop.

I'm not sure what's the best way to prevent this error. Perhaps forcing editing through the first domain of the site, or ignoring the redirect when pages are rendered in editing mode.

dyerc commented 3 years ago

Further update on the "stuck waiting for preview pane to load" issue... I experienced this again today and since I have already enabled the first domain redirect this couldn't be it.

This time it was a liquid error that prevented the page from loading correctly. The liquid error was very much my fault, but it would be nice if Locomotive could show some indication that a problem occurred when rendering the page.

The reason the editor appears to just keep loading and loading is related to the code here https://github.com/locomotivecms/engine/blob/bb2a3a3fa24adf4e953d2f96f8419eb032fadb16/lib/locomotive/steam/middlewares/page_editing.rb#L63 By the way the mechanism of injecting code into the page being loaded, triggering the editor to finish loading is ingenious 👏 @did

Since this event is never called, because the page fails to load, the editor just keeps waiting for it. 1) The editor could have a timeout of several seconds and then show a message saying the page failed to load 2) I guess it might be really awkward for the editor to show the liquid error here and it might not be appropriate for site editors to see the error message anyway.

Hopefully this write up helps anyone else who encounters this issue.

did commented 3 years ago

thanks @dyerc for reporting it! I set up a 20s timeout before displaying an error message at the center of the screen. Besides, I decided to show the sidebar (with all the sections) although the changes won't appear.