AshOban job failures
I have a job that runs using AshOban, which I find a very nice way of doing things tbh, as most things you've done so far!
However it seems to me that the only way to handle failures is to give it an action to run. For example setting the state to failed, however I'd like to be able to see the failure in Oban apart from setting the Resource as failed. I have scoured the documentation but I don't see a way of having the Oban job fail on failure. Am I missing something? Was there a specific reason this is like this?
14 Replies
๐ค Its a bit complex because we don't want the job to be retried or anything like that. I think we could change it to show the jobs as failed but it would require some way to return that from a job
like "this failed, but discard it" or something like that
Ah, I see. Basically you want to bypass Oban retry system.
Since you are handling it yourselves
Are you using Oban.Worker under the hood? Maybe
max_attempts
could be set such that that doesn't happen? Or that didn't work?Correct, we do. So actually it may not be an issue now that you bring it up ๐ค
because we just intercept when we are on the last attempt
So maybe we actually can just let it fail
Yeah, okay, so if you want to experiment with this, you could try cloning down
ash_oban
and in define_schedulers
(sorry for the state of that file), in this function head:
We just need to reraise the error at the end instead of doing :ok
okay, will try later tonight ๐
lines 720/723-ish
okay, it seems to work, will clean it up and may send a PR later
do we want to enable this behaviour all the time, or should we make it a configuration of the trigger?
For now we should make it opt in so as not to break applications
But make a command that includes the next major version number and we can change the default to be this new behavior
okay, so I can add a "fail_job_on_error" boolean, with default false
Yep. Although we may want to be careful with the wording
Because if there is no on_error then it does fail ๐
maybe just
fail_jobs
?
(although ash_oban is at 0.4.6, which means that under semver you are allowed to make breaking changes in minor versions ๐ )๐ still prefer not to ๐
of course of course ๐
@Zach Daniel https://github.com/ash-project/ash_oban/pull/159
GitHub
feat: Implement :fail_oban_job? option for triggers by MarceColl ยท...
By default AshOban doesn't fail the Oban job, this new option gives users the control wether they want to fail the job or not.
Contributor checklist
Features include unit/acceptance tests
Let me know if I'm missing anything important