AHBruns
Oban Pro Relay and `:infinity` timeouts
So, I’ve been using Oban.Pro, and specifically Oban.Pro.Relay recently to run API requests to 3rd party services. The idea being I can have a queue per third party service, then place a global rate limit on it which matches that service’s rate limit.
My question is, is it safe to use a timeout on my await call of :infinity?
There are times where if I makes an API call, I want my process to wait indefinitely for the API call’s response. However, I don’t want to deal with bugs based on processes hanging forever due to Relay.await missing a reponse. Does Relay.async guarantee that once it returns the job it enqueued will eventually run, and does Relay.await guarantee that it will return when the underlying job is run?
Trending in Questions
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
Beyond Safe Migrations: Better Practices for Ecto + PostgreSQL - Joe Harrow | ElixirConf US 2025
Comments welcome! View t...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 8 of 8 Posts
benwilson512
This depends a lot on what the process is doing, but in general you want to avoid infinite awaits and instead rely on an async method of completion notification.
AHBruns
To be clear, this is not about the await call itself. I could, for example, use Relay.async from a GenServer and handle the response messages myself similar to how one might interact with a Task.
Choosing to use Relay.await and block on a response vs listening for a response in a non-blocking manner is orthogonal to this question.
The question is if Relay will reliably return a response, or if it is possible for a response to be drop (or infinitely delayed). Any idea @sorentwo ?
lud
Hello @sorentwo , regarding the snooze behaviour, I would like to know if snoozing with zero will put the job at the “end” of the queue (jobs with same queue name and same priority) if all the jobs were enqueued with the default timestamp (no
schedule_inoption given for any job).@AHBruns I don’t know Relay but imagine for some reason something odd happens with the network, unrelated to Oban, and makes your API call to never return. Then your job will never finish, and if you want to stop and restart the BEAM it will have to be killed. It’s best not to have to deal with that so a generous timeout should be better, and the timeout for awaiting the job should be the same timeout plus a couple seconds.
I don’t know if it is configurable in Oban but you would have to set the same timeout for children termination in Oban supervisors somewhere.
sorentwo
Jobs always run in the order they were scheduled, assuming the same priority. When jobs all have the same timestamp then the
idacts as a secondary sort, where earlier jobs run first.Snoozing with a 0 timeout will reschedule it at the current time. At that point, all the usual ordering applies, e.g. the snoozed job will run after anything inserted before it.
AHBruns
My question was moved, so not sure if here is the best location to continue discussing, but I’ve designed my jobs to always return, in the worst case, the API call they are running hit its timeout, and then the job returns.
The problem with just setting a larger timeout on my Relay.await call is 2 fold
benwilson512
Hey all sorry for the forum noise, all the relevant posts should be here now. @sorentwo requested that I move these posts since he wanted a chance to dig into the questions here in more depth without cluttering up the general thread.
AHBruns
Apologies for the hassle!
sorentwo
Relay uses normal queue functionality to insert the job and await execution. If that queue is backed up then it may take a little while before the job executes. Once the job processes the response is broadcast back to the listening process. Assuming the process is still listening, it will receive the reply.
I recommend using a shorter await timeout and re-awaiting a few times so the process doesn’t hang too long.