From e1162a94c69e39ce53de0edbe380d83ce67e0ac9 Mon Sep 17 00:00:00 2001 From: Bart Nagel Date: Wed, 25 Feb 2015 17:17:28 -0800 Subject: [PATCH] Release jobs which cause exceptions back to the queue From @pulkitjalan's patch 5ae35aec11051dbe8dd2a02489c8c39bd0eee0c2 If an exception is encountered while working on a queued job to submit an error to Sentry, this exception would be caught and added to the queue as another job. This can snowball and cause all sorts of problems. Instead, catch any exception thrown when trying to submit an error and ignore it, instead releasing the original error submission job back to the queue after a delay. Note that this does not protect against similar issues when synchronously submitting error reports. --- src/Handler/Laravel/Job.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Handler/Laravel/Job.php b/src/Handler/Laravel/Job.php index d3fee41..46de343 100644 --- a/src/Handler/Laravel/Job.php +++ b/src/Handler/Laravel/Job.php @@ -59,7 +59,11 @@ public function fire(IlluminateJob $job, array $data) $this->transport = new $data['transport']['class']($data['transport']['options']); } - $this->transport->send($data['url'], $data['data'], $data['headers']); - $job->delete(); + try { + $this->transport->send($data['url'], $data['data'], $data['headers']); + $job->delete(); + } catch (\Exception $e) { + $job->release(30); + } } }