sheharyarn / que

Simple Job Processing in Elixir with Mnesia :zap:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Worker is an Invalid Worker

mbaeuerle opened this issue · comments

I have an issue with the worker. I can start the application just once and it runs (in iex).
But when I want to rerun it (by starting a new iex session), I get the Worker is an Invalid Worker error.
I can only fix that by renaming the Worker. Then it works again once before I have to rename it again.

I am using Elixir 1.4.2 and Que 0.3.1

Hi @mbaeuerle. Can you post the code for the worker, the code you're calling and the stack trace?

I created a minimal project where I could reproduce the problem. The worker looks like this:

defmodule Worker do
  use Que.Worker

  def perform(work) do
   IO.puts work 
  end
end

And adding to Que like this:

  def hello do
    Que.add(Worker, "1 test")
  end

Now running it the first time is no problem. The second time the error occurs:
grafik

I think this has something to do with compiling the file. Everytime it is compiled (ie. when changing the code) something else is done which is not done when just rerunning it.

This is indeed a serious bug @mbaeuerle, thank you for reporting it. It seems like an issue with how the Erlang VM lazy loads some modules. In my tests, this happens randomly. I'm working on a fix right now.

I've released a new version with the patch. You should not have this problem any more.

Thanks for fixing so fast!