Error handling liveview: keeps crashing during rendering and restarting repeatedly, generating a large number of errors

Hi,

I’m currently in the process of rewriting our React app to LiveView. So far, everything is working well, but I’ve run into an issue.

When I feature-switched the first users to the LiveView frontend, some of them ended up in an error loop. The view kept crashing during rendering and restarting repeatedly, generating a large number of error logs and leaving the users confused.

I attempted to handle this with a try/rescue block in the render function, but I’ve since learned that this isn’t where HEEx is actually executed.

In an ideal case, I’d like to catch these errors and redirect the user to an error page or otherwise fail more gracefully.

Any ideas would be greatly appreciated.

Marcus

Any idea why the liveview crashes? Might just be a handle_info or something you haven’t implemented

Just edge cases in the code that we have not tested before and faced on production, liker accessing structure attributes that we nil and things like that. I know, this should be handled by unit tests, but it is a big system and limited developer resources.

LV doesn’t really have that kind of error handling. It tries to resolve errors the same way supervisors do - trying again. This is useful for transient errors like an api being down or some temporarily wrong value slipping into your state. Knowing when an error can never be resolved by retrying is not really possible.