Comments (2)
This is an interesting idea. There are a few challenges in this approach, namely returning correct exception and stacktrace information.
We could have some code to manually
raise
/throw
inside our job module, but it feels like something that Oban could handle by itself (I don't know how other elixir libraries deal with it).
According to my preliminary investigations other libraries handle this in a variety of ways. Some require returning an explicit :ok
or the job is considered a failure, others require you to commit a transaction, and some others require explicit retries.
I intentionally avoided requiring an :ok
return value, but the idea of checking for an error tuple has promise.
If
perform/1
returns{:error, error}
, I thinksafe_call
should return{:failure, job, :error, error, __STACKTRACE__}
and the job will be treated as failed, and the scenario where exceptions were raised should use:exception
instead of:error
for thekind
prop (this makes easier for the event listeners to know it's an actual exception or some other data structure that represents the error).
Differentiating between an "error" and an "exception" could be very useful in debugging. However, there are some technical difficulties to consider:
- The
kind
value is used byException.blame/3
and friends to format the exception and the stacktrace. The kind is:error
to denote what we're calling an exception here, so that may require some refactoring to work around. - The
__STACKTRACE__
macro is only available inside of arescue
orcatch
block. The best we can do outside of the block isProcess.info/2
, which isn't always accurate. - What is the datatype for
error
in this situation? Is it an atom, a binary, an exception struct? CallingException.normalize/3
orblame/3
on a binary or atom will result in an%ErlangError
wrapping it, which may obfuscate the initial error message entirely.
I'll think about this a little more and see if I can work out a suitable implementation. 👍
from oban.
Closing in favor of the PR, #20
from oban.
Related Issues (20)
- Structs cannot be passed to Job.new HOT 3
- Notifier logs after upgrading to 2.17.4 HOT 18
- Upgrading to Oban 2.17.4 from 2.17.3 fails compilation step with `no function clause matching in Ecto.Query.with_cte/3 ` HOT 1
- Oban 2.17.4 update MATERIALIZED syntax error HOT 3
- Oban Web is refreshing the page constantly HOT 1
- Unclear docs for `perform/1` callback in case of an unhandled exception, exit or throw HOT 1
- Crontab information in Oban jobs (or job-related Telemetry events) HOT 7
- Potential bug: available jobs not being run HOT 4
- (Postgrex.Error) ERROR 42601 (syntax_error) on deploy HOT 1
- Enqueueing a job with a non-serializable value (changeset) causes error HOT 1
- Oban.Pro.Testing - Upgrade from 1.3.2 `ensure_queues_started` "process not alive" HOT 6
- Oban.Pro.Worker Hook Docs HOT 1
- oban_web - `KeyError` in `Oban.Web.Jobs.SortComponent.render/1` HOT 5
- Add `crontab: false` to recommended test config HOT 5
- `FunctionClauseError` in `Registry.keys/2` HOT 2
- `not_null_violation` Postgres error for Oban scheduled job HOT 8
- Config for Oban.Met? Not seen this before from AppSignal HOT 5
- Oban.Pro.Workers.Chain with test inline mode causes Ecto error on comparison with nil id HOT 1
- Oban - Partitioning by worker and args at the same time does not work HOT 2
- with_testing_mode is ignored if enqueuing within another process HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oban.