Phoenix Endpoint crashing

I check my logs today in production and found below error logs indicating the crashing of my phoenix server endpoint.

request_id=FfJ7ijs3cGTfqa8AHM_B [error] 3914- fatal: :expected_element_start_tag
[error] #PID<0.21588.4> running DebitorWeb.Endpoint (connection #PID<0.21587.4>, stream id 1) terminated

I think :expected_element_start_tag per what I stumbled upon is related to xmerl - I’m using SweetXml which is a wrapper around xmerl.

Will I be right in concluding that this is what is causing the crashing of the Endpoint - can I simply wrap the library in a try and catch block to resolve this issue.

Thanks.

:wave:

Will I be right in concluding that this is what is causing the crashing of the Endpoint - can I simply wrap the library in a try and catch block to resolve this issue.

What for exactly? I’d prefer a crashing endpoint (note this is not the whole application, but a single connection/stream process pair crashing) with a log trace.

That sounds comforting, I was a bit worried it was affecting the entire endpoint. BTW - it’s a transactional processing system and I will be much more comfortable trapping and logging all exceptions rather than have it crashed. Please advise if wrapping SweetXml in try and catch will help.

trapping and logging all exceptions rather than have it crashed

But they are logged with a stacktrace by default, no? And why would you want to trap them?

I want to avoid the spawned process crashing- per how cowboy handles request, if the process crashes, only the crash report is logged. I want to be able to catch xmerl exception, log it with the exact xml string and possibly proceed to run other api calls.

1 Like

Ah, I see. Then, I guess, yes, trapping is one of the possible approaches. You can also try parsing in a separate process which is not linked but monitored by the request processes.