-
Notifications
You must be signed in to change notification settings - Fork 125
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
PubSub registry fails to start or race condition when testing? #155
Comments
I recently upgraded the pubsub dependency in my project following the documentation, but I am getting this error whenever I run the server:
Here is my application.ex
It happens occasionally not all the time as other users reported. |
Hi there, I am facing similar issues, I had updated to version 2 and now I am confused, the code documentation establish this as a valid example - name as an atom {Phoenix.PubSub, name: :my_pubsub}, What's the correct one? my test suite is failing since multiple errors like |
@sashaafm What does the test look like that is causing the issue? I know it's silly, but since you've confirmed pubsub is starting first in the supervision tree, is it possible there is a typo in the name MyAppServer.PubSub when you call broadcast? Also, if there is or isn't an alias present in that file, that's tripped me up in the past. |
I'm having this very random issue (it only happens occasionally, let's say 40% of the time) where it looks like my tests fail because they can't publish to my
Phoenix.PubSub
. The errors are all similar to this one:the stack trace points to
phoenix_pubsub/lib/phoenix/pubsub.ex
Line 144 in 7893228
PubSub
but it is quite simple and only calling thePubSub
API.I've also seen this issue #144 where it looks like the author was having a similar problem. However, it seems like he fixed it by having the correct child order in his top-level supervisor.
My top-level supervisor children is the following:
and by the docs of all applications I believe it is correct.
I cannot find a reason for this to be happening. It's completely random and sometimes I can execute my test suite many times and it will never happen. Sometimes it will happen occasionally and other times it will be more frequent.
My
test_helper.exs
also has nothing out of the ordinary:this issue has never happened in the
dev
environment, however it has been plaguing mytest
environment for quite a while.Any tips on how to solve this issue? Thanks!
EDIT 1: I've found that this issue is reproducible using the
seed
given at the end of the test suite. I'll try to start from here to understand the problem at hand.EDIT 2: Adding
Application.ensure_all_started(:my_app_server)
to thesetup_all
callback of the test files belonging to the top-level supervisor children seems to have fixed this issue (at least for the seeds I knew could reproduce the problem). However, I'm still unaware of the root cause.The text was updated successfully, but these errors were encountered: