How to deal with timeout issue when debugging Phoenix app

Article autor
April 20, 2021
How to deal with timeout issue when debugging Phoenix app
Elixir Newsletter
Join Elixir newsletter

Subscribe to receive Elixir news to your inbox every two weeks.

Oops! Something went wrong while submitting the form.
Elixir Newsletter
Expand your skills

Download free e-books, watch expert tech talks, and explore open-source projects. Everything you need to grow as a developer - completely free.

Table of contents

There is a common scenario: You'd like to debug your Phoenix app with break!/4 or IEx.pry/0. Everything works fine, until... Phoenix server throws a timeout error statement.

** (EXIT from #PID<0.5227.0>) shell process exited with reason: shutdown

It happens after about 60 seconds. Why?

The process has a certain amount of time to send a response. If it takes more - then the server says: "It takes too long. The process is probably suspended and in the meanwhile, the Client/user is raging on the other side. Let's kill him... (the process, not the user)".

Usually, it's a very nice, and helpful logic. But in the case of debugging it might be a real pain in the neck.

As soon, as we know the reason, we're able to find the solution. And here we are. Just set the idle_timeout option at your endpoint config. Generally at config/dev.exs, or so.

config :appname, Appname.Endpoint,
  http: [
    protocol_options: [idle_timeout: 5_000_000_000],
    ...   
  ]

Work with a team that keeps learning and building better software every day.

Related posts

Dive deeper into this topic with these related posts

No items found.

You might also like

Discover more content from this category

Manually update Apollo cache after GraphQL mutation

Ensuring that GraphQL mutations properly update your Apollo client's cache can be a bit tricky - here's how to manually control that.

How to get the struct type in Elixir

So you don’t know what’s the type of struct you’re passing somewhere? Maybe it can be one of few types and you have to distinguish them? Or any other reason… But it’s about checking the struct type. Just use one of the coolest Elixir features - pattern matching!

How to override Kernel macros

The macro mechanism in Elixir is not only an interesting metaprogramming feature - in fact, it is at the language's very core. And the more awesome fact is that, using macros, you can override the algorithm of defining functions itself!