Rodeoclash

Rodeoclash

I have an odd problem with a GenServer receiving a :DOWN message when I’m not expecting it. The GenServer itself is responsible for polling an external service every n number of minutes and making sure that I have a matching monitored process in my Elixir app. The file itself can be viewed here:

It is started in my application.ex using worker(App.KubernetesV2.Monitor, []).

Every now and again it will receive a message similar to: {:DOWN, #Reference<0.3921202181.3305373697.88131>, :process, #PID<0.7999.9>, :normal}. From my reading, this message should be sent when a process monitored has crashed or otherwise gone down. My question is, why is this server receiving the message? As far as I can tell, it shouldn’t be monitoring anything.

Showing Posts 1 to 4

david_ex

david_ex

That depends on what you mean by “otherwise gone done”: a :DOWN message is sent when the monitored/supervised process exits. It’s important to realize that the exit message will also be sent when a process exits normally (i.e. NOT having crashed), which is what is happening in your example: the :normal reason indicates that the process has exited “successfully”.

Basically, for what you’re attempting to do, you need to match the :DOWN messages in the handle_info: only report the exit reasons that aren’t :normal (if that’s indeed what you’re aiming for).

Rodeoclash

Rodeoclash OP

Sorry, that was a silly typo. It should be “gone down”.

I’m more curious about why I might be getting the message at all, rather than trying to match on it and handle it. Another bug I’ve been working through might be related to this. If an HTTPoison (or other process) launched from this GenServer crashes, could I expect the :DOWN message to originate from that?

david_ex

david_ex

Let’s quickly recap what :DOWN messages are and how they work, just to make sure there’s no confusion there.

A given process will typically receive a :DOWN message because:

  • a process it was monitoring has exited
  • a linked process has exited and the current process is trapping exits

Notice that the condition for getting a :DOWN message is simply “process exited” and NOT “process crashed”.

Now that that’s out of the way, let’s go over some points in your post that may help you debug.

why I might be getting the message at all

You were either monitoring the process, or were linked to it while trapping exits. As far as I can tell, you’re not trapping exits in the GenServer, therefore the :DOWN message is likely due to a monitored process exiting.

rather than trying to match on it and handle it

Usually, if you’re interested n :DOWN messages, you’ll match on them, because in most cases you want to run different logic if the downed process exited normally or if it crashed (e.g. you typically don’t want to report successful exits to crash reporting services). Since receiving a :DOWN message only tells you that a process has exited, you need to match on the reason value (i.e. :normal in the message you posted) to determine whether the exit was due to a crash or not.

If an HTTPoison (or other process) launched from this GenServer crashes, could I expect the :DOWN message to originate from that?

No: it would send a :DOWN message, but not the one you posted. The posted one has a :normal exit reason, therefore it wasn’t due to a process crashing.

Hope this helps!

Rodeoclash

Rodeoclash OP

Ok, well the recap certainly helps and has given me something to think about, thanks @david_ex. I’m still unsure how I could be monitoring or linking a process in that GenServer code but it’s given me a starting point!

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews