Can LiveView Phoenix Sites Run without Much Modification on Heroku? Timeout Issues

I’ve tried looking up, basically, the title but any issues that’ve been brought up haven’t seemed to apply.

I’m not setting check_origin, any, and (even with it set) I don’t get any difference in behavior and things run flawlessly when I run the app. locally.

It’s not even that the behavior is erroneous once the LiveSocket connects (when deployed) – it just often can hang and timeout a few times before successfully mounting (and that’s after I changed the timeout to 50000).

There’s no error that I can see in the Heroku logs and, after doing liveSocket.enableDebug();, the only error it reports is timeout.

I’m only using LiveView for an infinite scroll functionality which loads 20 posts and, when you get towards the bottom, loads the next 20 (it’s very isolated to just the posts and is loaded via a live_render). The posts utilize a few View templates which are relatively busy in computations but, once the LiveSocket connects, I don’t have any more trouble (no matter how many more 20 posts I load); it’s just getting things to connect that first time.

I also have a Websocket running (might convert the functionality to a LiveView if feasible, if I can get things to work…) and that’s never had any trouble whatsoever. I tried disabling it in case it was causing trouble with the LiveSocket but no change in behavior.

I’m happy to share any code anyone thinks might be useful but, like I mentioned, there doesn’t really seem to be any issue with the functionality (other than the initial mount); it just is really hit or miss as to whether it’ll mount (and, even when it does on the first time, it usually take 30–45 seconds before it does).

Anyone possibly know anything that might be a cause? My suspicion is Heroku but, of anything I could find, most recent (granted, self-)reports said Heroku should be fine for LiveView.

Tangential but would anyone know if there’s a way to not have the page refresh if timeout does occur 10 times? I don’t know that this is the structure I’ll go with if this is something I have to live with but, if I do, it becomes difficult to provide something like a “Next Page” button as a fallback if the page is going to just refresh on the user suddenly.