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

Raise may call an atom - undefined module #76

Open
tomdos opened this issue May 18, 2021 · 2 comments
Open

Raise may call an atom - undefined module #76

tomdos opened this issue May 18, 2021 · 2 comments

Comments

@tomdos
Copy link

tomdos commented May 18, 2021

There is an issue in catching an exit here https://github.com/joaomdmoura/machinery/blob/master/lib/machinery.ex#L95

The raise expect a module or a string. However it may get an atom and Elixir will try to call exception/1 from that atom which obviously fails.

How to reproduce it:

Machinery.transition_to(A, :b_parma, :c_param)

Output:

17:15:41.494 [error] GenServer Machinery.Transitions terminating
** (UndefinedFunctionError) function :b_parma._machinery_initial_state/0 is undefined (module :b_parma is not available)
    :b_parma._machinery_initial_state()
    (machinery) lib/machinery/transitions.ex:24: Machinery.Transitions.handle_call/3
    (stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:690: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.1595.0>): {:run, A, :b_parma, :c_param}
** (UndefinedFunctionError) function :undef.exception/1 is undefined (module :undef is not available)
    :undef.exception([])
    (machinery) lib/machinery.ex:113: Machinery.transition_to/3

As you can see I used undefined module and this gets to raise which tries to call :undef.exception/1 which is undefined as well.

Maybe as a quick fix changing raise to throw may work or removing catching at all?

@joaomdmoura
Copy link
Owner

Good catch @tomdos! I'll look into it next week and try to cut a new minor version with the fix

@dfang
Copy link

dfang commented Jan 24, 2022

@joaomdmoura i got a similar error:

** (UndefinedFunctionError) function :calling_self.exception/1 is undefined (module :calling_self is not available)
    (machinery 1.0.0) lib/machinery/transition.ex:142: Machinery.Transition.callbacks_fallback/4
    (machinery 1.0.0) lib/machinery/transitions.ex:52: Machinery.Transitions.handle_call/3
    (stdlib 3.14) gen_server.erl:715: :gen_server.try_handle_call/4
    (stdlib 3.14) gen_server.erl:744: :gen_server.handle_msg/6
    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.4315.0>): {:run, %Tiktok.Orders.OrderDetail{__meta__: #Ecto.Schema.Metadata<:loaded, "order_details">, amount: 9197443, category_id: 2, id: 335, inserted_at: ~U[2022-01-24 04:35:18Z], name: "xxx, order: #Ecto.Association.NotLoaded<association :order is not loaded>, order_id: 34, resolved_at: nil, state: "pending", updated_at: ~U[2022-01-24 04:35:18Z]}, Tiktok.Orders.OrderDetailStateMachine, "resolved"}
13:08:04.940 [info] Application machinery exited: shutdown

and errors from oban

{"{\"at\": \"2022-01-24T05:46:51.250284Z\", \"error\": \"** (UndefinedFunctionError) function :noproc.exception/1 is undefined (module :noproc is not available)\\n    :noproc.exception([])\\n    (machinery 1.0.0) lib/machinery.ex:109: Machinery.transition_to/3\\n    (tiktok 0.1.0) lib/tiktok/workers/simulators/resolve_order_detail_simulator.ex:67: Tiktok.Workers.Simulators.ResolveOrderDetailSimulator.perform/1\\n    (oban 2.9.2) lib/oban/queue/executor.ex:212: Oban.Queue.Executor.perform_inline/2\\n    (oban 2.9.2) lib/oban/queue/executor.ex:200: Oban.Queue.Executor.perform_inline/2\\n    (oban 2.9.2) lib/oban/queue/executor.ex:82: Oban.Queue.Executor.call/1\\n    (elixir 1.12.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2\\n    (elixir 1.12.3) lib/task/supervised.ex:35: Task.Supervised.reply/5\\n    (stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3\\n\", \"attempt\": 1}"}

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

3 participants