Each of the sub-workflows work perfectly fine on their own, but when run from the orchestration, I get this error:
** (RuntimeError) module is not a worker: Oban.Pro.Workers.Context
I assume this has something to do with the fact that Oban.Pro.Workers.Context is a virtual module registered like: Job{worker: Oban.Pro.Workers.Context}
I can kinda work around this by grafting in the workflow, but that shouldn’t be necessary, and it would be better to be able to use the sub-workflows via add_workflow/4
I am seeing this issue in testing. I actually do not believe it appears when running the job normally, but I have refactored the child workflows to do something like this:
parent_workflow_id = Keyword.get(opts, :parent_workflow_id, nil)
workflow =
case parent_workflow_id do
id when is_binary(id) ->
Workflow.new()
nil ->
Workflow.new()
|> Workflow.put_context(%{
source_name: to_string(source_name),
batch_size: batch_size
})
end
And just make sure I have the orchestration workflow set the correct context. I can un-refactor it if you want me to check the difference between test/dev environments, but I do recall it works fine outside of test.
Are you testing with inline mode? If so, that would cause a problem. Workflows aren’t really compatible with inline mode because the jobs never hit the database. They are executed in memory in insert order, which doesn’t exercise the workflow dependencies at all.
Testing workflows should be done with the run_workflow/1 Pro testing helper, or manual draining from manual testing mode if needed.
Okay I tried run_workflow/1 and also re-checked in dev mode with my workaround removed. Both cases actually act identical to testing in :manual mode with drain_jobs/1.
I.E.: ** (RuntimeError) module is not a worker: Oban.Pro.Workers.Context
When actually trying this out at runtime in dev mode, the workflow actually runs correctly, but the MapperWorkflow’s Oban.Pro.Workers.Context fails with the following meta:
%{
...
}
The MapperWorkflow then continues on to work correctly, I assume with the parent’s context (though I haven’t validated whether that is true)
Update on this—we were able to reproduce the issue and there’s a fix on main ready to go out with the next patch. Thanks again for such detailed investigation work!