You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am implementing the PubNub gem in my Rails app. I use ActiveRecord callbacks as a hook to publish events when a model is created/updated/destroyed/etc. So I've been using the Rails console extensively as I develop to chain together a series of statements that create a variety of model instances, save them and then I monitor the PubNub dev console for my published event (the PubNub dev console is very helpful, btw).
pubnub gem 3.5.1
Rails/Puma
Issue
Sometimes when publishing a message I would get an exception noting that the Event Machine hadn't started.
eventmachine not initialized: evma_install_oneshot_timer
The same set of statements would sometimes result in the exception, sometimes not. Based on some quick research and a bit of conjecture, it seems that the first publish invocation would prompt EM to start, but before it completed initializing, another publish invocation occurs and results in the exception. Like I said, just speculation on my part.
Fix/Workaround
Based on a search of the error message, I came across a fix where as soon as you start EM, have that thread wait until EM is up and running before continuing. I put this in a rails initializer and I haven't had the problem since. Cheers
@rhettc thanks for providing example fix! I see now i lost one line while refactoring from 3.4, i think it won't be necessary to include that in rails initializer (after adding that lost line), but i have to made some tests. I will keep you informed!
Backstory
I am implementing the PubNub gem in my Rails app. I use ActiveRecord callbacks as a hook to publish events when a model is created/updated/destroyed/etc. So I've been using the Rails console extensively as I develop to chain together a series of statements that create a variety of model instances, save them and then I monitor the PubNub dev console for my published event (the PubNub dev console is very helpful, btw).
pubnub gem 3.5.1
Rails/Puma
Issue
Sometimes when publishing a message I would get an exception noting that the Event Machine hadn't started.
The same set of statements would sometimes result in the exception, sometimes not. Based on some quick research and a bit of conjecture, it seems that the first publish invocation would prompt EM to start, but before it completed initializing, another publish invocation occurs and results in the exception. Like I said, just speculation on my part.
Fix/Workaround
Based on a search of the error message, I came across a fix where as soon as you start EM, have that thread wait until EM is up and running before continuing. I put this in a rails initializer and I haven't had the problem since. Cheers
The text was updated successfully, but these errors were encountered: