Skip to content

Commit fe0505d

Browse files
committed
feat: Refactor FetchResourcesJob with ActiveJob::Continuable
- Add `ActiveJob::Continuable` for improved job handling. - Remove `retry_on Ferrum::ProcessTimeoutError` to simplify error handling. Signed-off-by: Manon Budin <manon.budin@beta.gouv.fr>
1 parent e26f894 commit fe0505d

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

app/jobs/fetch_resources_job.rb

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
class FetchResourcesJob < ApplicationJob
2+
include ActiveJob::Continuable
3+
24
queue_as :slow
35

46
rescue_from(Ferrum::StatusError, Ferrum::TimeoutError) do |exception|
57
Rails.logger.debug("Failed to fetch SOME home page HTML because: #{exception}")
68
end
79

8-
# sometimes the underlying Chrome process is [defunct], as show when
9-
# inspecting the jobs container with `ps -ef`: it hasn't been killed
10-
# properly so SolidQueue has to wait and timeout the job on
11-
# Ferrum::ProcessTimeoutError. Failing the job seems to get rid of
12-
# the defunct process, so maybe killing the corresponding thread
13-
# (within the process) is enough to clear up the process.
14-
retry_on Ferrum::ProcessTimeoutError
15-
1610
def perform(audit)
17-
FetchHomePageService.call(audit)
18-
FindAccessibilityPageService.call(audit)
11+
step :start do
12+
Rails.logger.info("Started for #{audit.url}")
13+
end
14+
15+
step :fetch_home_page do
16+
FetchHomePageService.call(audit)
17+
end
18+
19+
step :find_accessibility_page do
20+
FindAccessibilityPageService.call(audit)
21+
end
22+
1923
ensure
2024
ProcessAuditJob.perform_later(audit)
2125
end

0 commit comments

Comments
 (0)