In your AssignUser.on_mount, during the disconnected rendering that happens first, the assign_new uses the :current_user
set in the Plug pipeline by UserAuth.fetch_current_user
(see doc). This uses Accounts.get_user_by_session_token
that doesn’t have the preload you want so it crashes.
If you navigate to this page while being already connected on the websocket, it can’t reuse the :current_user
so it has to fetch it via Accounts.get_user_by_session_token_with_parameter
that has the good preload so it works.