You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ask this question in the issue section, it should be here.
I'm looking for a way to retry a job depending on the error I got from an http request.
So when I read the documentation I only see the possibility to give a fixed retries parameter in the job options.
In this case I receive from a webservice a http response. When it has http status 503 or 504 I would like to retry.
What would be the correct way to implement this?
@compwright already responded:
In your worker, you should catch the web service errors in a try...catch block and decide there how to handle the error. For the errors you want to retry, re-throw the error inside the catch block. For the errors you do not want to retry, do not throw. Log, send the error somewhere (like Sentry), or return some response, but don't throw any error you don't want retried.
I understand your solution. But this doesn't feel right. You 're suggesting to setup de worker to always retry, and then in try..catch block decide. But most cases I don't wanna retry at all, even in a 503 case. Maybe this is the only option, that i'll do it with that.
But isn't there a way to re-queue a job under condition?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I ask this question in the issue section, it should be here.
I'm looking for a way to retry a job depending on the error I got from an http request.
So when I read the documentation I only see the possibility to give a fixed retries parameter in the job options.
In this case I receive from a webservice a http response. When it has http status 503 or 504 I would like to retry.
What would be the correct way to implement this?
@compwright already responded:
In your worker, you should catch the web service errors in a try...catch block and decide there how to handle the error. For the errors you want to retry, re-throw the error inside the catch block. For the errors you do not want to retry, do not throw. Log, send the error somewhere (like Sentry), or return some response, but don't throw any error you don't want retried.
I understand your solution. But this doesn't feel right. You 're suggesting to setup de worker to always retry, and then in try..catch block decide. But most cases I don't wanna retry at all, even in a 503 case. Maybe this is the only option, that i'll do it with that.
But isn't there a way to re-queue a job under condition?
Beta Was this translation helpful? Give feedback.
All reactions