clemensm

clemensm

Phoenix Channel sometimes stop working because :handle_info function is no longer exported

Hi there

I’ve run into a really strange problem in one of my apps recently, which I sadly cannot reproduce reliably but do see from time to time in :dev and :prod environments.

So I’ve got an app where users can create “cards” with some content on them, and we’ve got a list of all cards the user owns where he can search for his cards. The searches can be quite complicated, so what we’ve implemented is that the search request is send to the server which performs the search and then sends back the result in form of rendered html as a string. The result itself is sent using a channel called “search:unique_identifier_for_each_search_instance”, to which the client subscribes on loading of the app. The html is then received on the client and the current table with the results is replaced with the received new result.

This all is a bit more complicated then necessary, but a lot of this functionality has grown over time, so for now it is what it is :slight_smile:

Now the socket that the channel belongs to hosts multiple channels, e.g. another one is “alert:user_id” in order to send the user information if something goes wrong, of ir new cards are received from other users, just in case this might be important.

So finally the problem: Usually all this works fine, but from time to time what can happen is, that if the user navigates back in the browser (the frontend is an SPA, so the socket is not remounted), suddenly the search results are no longer sent to the client. Instead I get an error like this:

[warning] Phoenix.Channel.Server #PID<0.1296.0> received unexpected message in handle_info/2: 
{:new_result,   lots_of_html_here_that_is_truncated ......

So looking into the code of Phoenix.Channel.Server I found the place that triggers the message, and this only happens if function_exported?(MyApp.Channel.Search, :handle_info, 2) returns false. However the MyApp.Channel.Search module does actually export that function.

Next luck would have it that I triggered this error shortly afterwards while running the server using iex -S phx.server, and quickly checking the output of function_exported?(MyApp.Channel.Search, :handle_info, 2) in the console manually, the call does indeed return false. However after some digging around and trying it again, it now returns true, and the search also starts working as expected again. Also if I try function_exported?(MyApp.Channel.Search, :handle_info, 2) directly after starting the server, it also always returns true.

Does anyone have any idea how this can happen?

Thanks for your time already :smile:

Most Liked

derek-zhou

derek-zhou

Are you running a release? With a release, the BEAM is in the embedded mode and barring from hot code reloading, the function_exported? shall always return the same value.

Iex is interactive mode, so the code may not be loaded, if no one has called any function in that module.

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
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
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
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
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
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 54120 245
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement