vectordotdev / timber-elixir

🌲 Great Elixir logging made easy
https://timber.io
Other
214 stars 29 forks source link

GenServer Termination on Protocol.UndefinedError for MsgPacker #283

Closed ashutoshrishi closed 6 years ago

ashutoshrishi commented 6 years ago

There is a GenServer termination in the Timber logger, whose origin I cannot track. It's hard to tell which Logger call caused it.

I have a feeling that it is failing to log ecto structs in the Plug.Conn private context in the response, since I cannot find any explicit Logger calls which log the full struct or big structures.

I am encountering this error in my logs:

(Protocol.UndefinedError) protocol Msgpax.Packer not implemented for {"prefix_test", "institution_names"}. This protocol is implemented for: Atom, BitString, Float, Integer, List, Map, Msgpax.Bin, Msgpax.Ext

Followed by another error:

GenServer #PID<0.1093.0> terminating ** (stop) {:EXIT, {%Protocol.UndefinedError{description: "", protocol: Msgpax.Packer, value: {"prefix_test", "institution_names"}}, [{Msgpax.Packer, :impl_for!, 1, [file: 'deps/msgpax/lib/msgpax/packer.ex', line: 18]}, {Msgpax.Packer, :pack, 1, [file: 'deps/msgpax/lib/msgpax/packer.ex', line: 87]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}]}} Last message: {:gen_event_EXIT, Timber.LoggerBackends.HTTP, {:EXIT, {%Protocol.UndefinedError{description: "", protocol: Msgpax.Packer, value: {"prefix_test", "institution_names"}}, [{Msgpax.Packer, :impl_for!, 1, [file: 'deps/msgpax/lib/msgpax/packer.ex', line: 18]}, {Msgpax.Packer, :pack, 1, [file: 'deps/msgpax/lib/msgpax/packer.ex', line: 87]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}, {Msgpax.Packer.Map, :"-pack/1-fun-0-", 3, [file: 'lib/msgpax/packer.ex', line: 129]}, {:lists, :foldl, 3, [file: 'lists.erl', line: 1263]}, {Msgpax.Packer.Map, :pack, 1, [file: 'lib/msgpax/packer.ex', line: 128]}]}}} State: {Logger, Timber.LoggerBackends.HTTP}
ashutoshrishi commented 6 years ago

I found the problem, found an event metadata map which contained an Ecto struct. It was that struct that was not encodable, especially the # Association not preloaded part.