Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected messages from wait_for_it when used with Genserver. #3

Closed
st23am opened this issue Aug 31, 2017 · 1 comment
Closed

unexpected messages from wait_for_it when used with Genserver. #3

st23am opened this issue Aug 31, 2017 · 1 comment

Comments

@st23am
Copy link

st23am commented Aug 31, 2017

link to example to reproduce = https://github.com/cincinnati-elixir/example_genserver_waitforit_bug

Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Interactive Elixir (1.5.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> ExampleGenserverWaitforitBug.start_link
{:ok, #PID<0.156.0>}
iex(2)> ExampleGenserverWaitforitBug.hello("world")
"Hello world"
iex(3)>
21:34:33.640 [error] ExampleGenserverWaitforitBug ExampleGenserverWaitforitBug received unexpected message in handle_info/2: {#PID<0.158.0>, 5000}
@jvoegele
Copy link
Owner

jvoegele commented Sep 2, 2017

I looked into this and discovered that the reason for the unexpected message was that wait_for_it spawns a waiter process to monitor for timeouts, but it was not properly killing the process when it was done waiting. I had been using Process.exit(waiter, :normal) to kill the waiter process but instead I needed to use Process.exit(waiter, :kill) to forcefully kill the waiter process. I've made this change in master and the next release will include this fix.

Note that if you are using WaitForIt in a GenServer.handle_call callback, your wait timeout must be less than the timeout used when invoking GenServer.call, which by default is 5 seconds. Otherwise, your GenServer.call will timeout before your WaitForIt.wait call times out, leading to the following error:

** (exit) exited in: GenServer.call(ExampleGenserverWaitforitBug, {:request_greeting, "worldz"}, 5000)
** (EXIT) time out

@jvoegele jvoegele closed this as completed Sep 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants