derek-zhou

derek-zhou

How to suppress NoRouteError in Phoenix 1.7.2 and Bandit?

Ever since I upgrade to Phoenix 1.7.2 and Bandit, my log file is polluted with junk such as:

14:38:32.113 request_id=F1pur8zunbgsR1kAAoIR [error] GenServer #PID<0.9364.14> terminating
** (Phoenix.Router.NoRouteError) no route found for GET /sitemap.xml (RoastidiousWeb.Router)
...

I don’t want to make a catch-all route just to do 404, and I don’t remember seeing this back when I was using cowboy. Is there a way to config the stack to suppress logging for NoRouteError only?

Marked As Solved

Also Liked

mtrudel

mtrudel

Creator of Bandit

I got most of the way through exactly what you suggested, but then realized that Phoenix isn’t actually supposed to be raising NoRouteError errors externally (see phoenix/lib/phoenix/endpoint/render_errors.ex at main · phoenixframework/phoenix · GitHub)

This looks like a loooooooongstanding error in Phoenix that’s been silently canceled out by Cowboy’s silent error handling.

I’m working up the last bits of a PR for Phoenix to correct this, at which point we’ll end up with a better end result:

  • Phoenix renders NoRouteError errors and doesn’t raise them further
  • Phoenix renders all other errors and raises them further
  • Bandit logs loudly on all errors it receives
  • Cowboy doesn’t log errors it receives

This will end up with Bandit continuing to log all non NoRouteError errors loudly, which is what we want in general. NoRouteErrors will be silenced within Phoenix, which is really the correct place to be expressing this logic.

Expect Phoenix PR by end of day.

mtrudel

mtrudel

Creator of Bandit

Yep, I agree this is sub-par. Fix is coming to Bandit in the next few hours to quell this logging.

mtrudel

mtrudel

Creator of Bandit

For posterity, this is merged and released as part of Phoenix 1.7.3

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43806 214
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36432 110
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54250 245
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement