lookbook icon indicating copy to clipboard operation
lookbook copied to clipboard

UI auto-refresh doesn't work in Rails 5.x

Open allmarkedup opened this issue 3 years ago • 10 comments

Websocket events are being sent from the server correctly, and the websocket client connects ok, but events are never received on the client side.

allmarkedup avatar Oct 02 '21 17:10 allmarkedup

Hm, I noticed this in a rails 7 application too. Still investigating , but your description fits perfectly with what we're seeing

muriloime avatar Feb 10 '22 16:02 muriloime

adding to the discussion: after 15 seconds or so a new GET request to /lookbook/cable is done , with log in js console "Lookbook websocket disconnected"

14:06:18 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:06:18 -0300
14:06:34 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:06:34 -0300
14:06:49 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:06:49 -0300
14:07:05 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:07:05 -0300
14:07:21 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:07:21 -0300
14:07:39 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:07:39 -0300
14:07:56 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:07:56 -0300
14:08:13 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:08:13 -0300
14:08:30 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:08:30 -0300
14:08:48 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:08:48 -0300
14:09:01 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:09:01 -0300
14:09:23 web.1    | Started GET "/lookbook/cable?uid=1644512545404" for ::1 at 2022-02-10 14:09:23 -0300

muriloime avatar Feb 10 '22 17:02 muriloime

Hey @muriloime - thanks for the information, I've been pretty busy over the last few weeks so haven't had a chance to look into this for Rails 7 yet. I'll hopefully have some time later this week to dig into it and will let you know if I make any progress on the issue.

allmarkedup avatar Feb 15 '22 08:02 allmarkedup

Hi @allmarkedup. my hypothesis right now is that this is not a rails 7/rails 5 specific issue, but rather some configuration on the app preventing the reload to work. since If I start a rails 7 app from zero it works fine

cheers

muriloime avatar Feb 15 '22 13:02 muriloime

Sorry for the unstructured responses. Each time I have an idea I come back to this issue =) In the case it helps, I am sending more info:

I see some differences in the websocket connections between a working and a non working app:

Working: (greenfield rails 7 )

image image

Non working ( brownfield rails 7)

image image

muriloime avatar Feb 15 '22 18:02 muriloime

Hey @muriloime I've tested with a clean install of Rails 7 and have confirmed the the auto refresh is working fine for me, so it may well be something specific to your app.

I've just released v0.6.0 that has a change to the default way that the preview iframe renders it's contents. It's pretty unlikely that this will help your issue in any way but maybe you could give it a try and just confirm that you are still having the same problem?

allmarkedup avatar Feb 17 '22 22:02 allmarkedup

I'm also having a problem of auto refresh not working on a rails 7 app (and not even on inline components, as reported in #90). It's a quite new app and I haven't touched the config that much. For what it's worth I'm using importmaps with tailwind.

Like the above screenshot I see the "Lookbook websocket connected" log, but checking the data on the socket I see the ping, but nothing else. I've tried with both the redis and async adapter.

xdmx avatar May 16 '22 19:05 xdmx

My issue is almost the same as: https://github.com/allmarkedup/lookbook/issues/47#issuecomment-1040619002

I see the connection starts but no broadcast is received by the client.

The app is recently upgraded from Rails 5.x to 6.1 I wonder if there is something unique in the Rails 6 action-cable that isn't present unless you build the app from the beginning on Rails 6 and whatever that thing is goes away in Rails 7?

regulus33 avatar Jun 16 '22 18:06 regulus33

UPDATE: we solved it (by accident you might say). We had been using Iodine for our app server in development and recently switched back to Puma. Now everything works beautifully.

regulus33 avatar Jun 21 '22 10:06 regulus33

Just to follow up on my comment above if it could help to others, after reading #98 I tried to disable workers in my development Puma config and now I get the auto refresh working,

xdmx avatar Jun 23 '22 00:06 xdmx

Closing this issue as the websocket problems have now been resolved as of Lookbook v1.0.5, so UI auto-refresh should finally now work for Rails 5.x apps now 😀

allmarkedup avatar Sep 21 '22 19:09 allmarkedup

FYI, I solved my issues above by setting WEB_CONCURRENCY=0 in puma

muriloime avatar Oct 25 '22 16:10 muriloime