Open dmorgan-fa opened 2 years ago
@dmorgan-fa ah ok yes, I know why that will be - I haven't accounted for it being mounted like that, but it should definitely support it.
I've got another minor websocket issue I've been meaning to look at so I'll try and get them sorted together. Thanks for the report 👍
@dmorgan-fa so I've spent a fair amount of time digging into this and I'm afraid to say I'm stumped :-(
I've fixed a couple of (related) issues (on main, not released yet) but I just cannot figure out why ActionCable is not connecting when the engine is mounted at root. I suspect it's something to do with Lookbook being an isolated Rails engine, and without a mount path Rails is trying to connect to the ActionCable server on the parent application or something like that. I've tried everything I can think of to work around it but nothing seems to work. Very frustrating.
As an aside, ActionCable is actually complete overkill for Lookbook, but I've not had much luck finding a (simpler) alternative. There is literally just a single 'updated' event that needs firing on the server and picking up on the client side so it's pretty annoying having to rely on a complex ActionCable setup. It's actually making me think I should investigate implementing an old-skool long-polling AJAX style 'socket' instead!
I'll label this as help wanted
in case anyone with more websocket skills than me can help and I'll keep you updated if I stumble across a fix.
No worries, thanks for the quick reply Mark!
Sorry to hear it's much more of a pain than we thought it would be 😅 As a workaround, I've remounted at /lookbook
and stuck in a redirect, so there's no urgency on this. Have a good weekend 👋
@dmorgan-fa so I believe I've finally fixed this issue 😃
The latest release (1.0.7) has a bunch of other websocket-related fixes in it, and off the back of that I thought I'd see if I could tackle this again to finally close it off. It's not released yet but I've just pushed a change to main
that means the websocket should now correctly trigger the UI updates even when Lookbook is mounted at root.
I'm going to go ahead and close this now and will include the fix the next release. Thanks again for bringing it to my attention!
We are experiencing the same problem on version 2.2.1
. Mounting lookbook at /lookbook
instead of /
solved it.
Let me know if I can help by providing examples.
Hey Mark, something that I've ran into recently:
When we mount the Lookbook engine at the root of the rails app, rather than
/lookbook
, websockets fail to connect and hot reloading fails.Demo here Console:
WebSocket connection to 'ws://cable/?uid=1646144935981' failed
Edit: I've also checked against the latest
0.6.1
, and the problem is still present.