Running IO.inspect on a socket without truncating the result?

Hopefully a very simple question… I am troubleshooting and would like to see all the contents of a given socket using IO.inspect(). I know about using limit: :infinity to show everything in maps, lists, etc without truncation but that doesn’t seem to work with sockets. The printing is truncated with ...

Another weird thing is the socket is printed as #Phoenix.LiveView.Socket<> instead of %Phoenix.LiveView.Socket{} like a normal struct. What is a #Name<> data structure and how is it different than a struct? Couldn’t find where in the docs it is mentioned.

IO.inspect(socket, limit: :infinity)

returns this truncated result:

   assigns: %{},
   changed: %{
     changeset: true,
     email: true,
     field_errors: true,
     form_error: true,
   endpoint: MyAppWeb.Endpoint,
   id: "phx-4dWXZ4j7",
   parent_pid: nil,
   view: MyAppWeb.RegistrationLive,

LiveView derives the Inspect protocol here:

This causes the output to only include the specified fields and outputs in the <> syntax. You can see an example at

You may be able to use the structs: false opt to IO.inspect to get access to it.

:structs - when false, structs are not formatted by the inspect protocol, they are instead printed as maps, defaults to true.

Thanks @sb8244, really appreciate it… been working with Elixir a couple years and amazingly have never read about the inner workings of the Inspect protocol and deriving.

1 Like