fix: initialisation issue with middlewares.

So yeah, apparently `function_exported?/3` doesn't ensure that the module in question is actually loaded.
This commit is contained in:
James Harton 2024-05-08 19:16:48 +12:00
parent 574f64d50a
commit 220227d459
Signed by: james
GPG key ID: 90E82DAA13F624F4

View file

@ -17,7 +17,10 @@ defmodule Reactor.Executor.Hooks do
initial_state: reactor.state
})
Utils.reduce_while_ok(reactor.middleware, context, fn middleware, context ->
reactor.middleware
|> Utils.reduce_while_ok(context, fn middleware, context ->
Code.ensure_loaded!(middleware)
if function_exported?(middleware, :init, 1) do
middleware.init(context)
else