mirror of
https://github.com/we-promise/sure.git
synced 2026-05-07 12:54:04 +00:00
Tighten retry exhaustion state handling
Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com> Agent-Logs-Url: https://github.com/we-promise/sure/sessions/ea7a06f4-8344-4a00-877a-eda8cdfdc16a
This commit is contained in:
@@ -108,7 +108,7 @@ class Sync < ApplicationRecord
|
||||
# Retry exhaustion can leave the sync in `pending` because we reset it
|
||||
# after each rate-limit error to make the next ActiveJob retry retryable.
|
||||
start! if pending?
|
||||
fail! if may_fail?
|
||||
fail!
|
||||
update!(error: error_message)
|
||||
end
|
||||
|
||||
@@ -167,7 +167,8 @@ class Sync < ApplicationRecord
|
||||
def reset_for_retry!
|
||||
# We intentionally bypass callbacks/state events here so the same sync record
|
||||
# can become retryable again without firing post-sync hooks or extra
|
||||
# transition side effects while the job is being retried.
|
||||
# transition side effects while the TwelveData rate-limit error is being
|
||||
# re-raised back to `SyncJob.retry_on`.
|
||||
update_columns(
|
||||
status: "pending",
|
||||
error: nil,
|
||||
|
||||
@@ -76,6 +76,18 @@ class SyncTest < ActiveSupport::TestCase
|
||||
assert_not_nil sync.failed_at
|
||||
end
|
||||
|
||||
test "fail_for_retry_exhaustion! marks syncing sync as failed" do
|
||||
sync = Sync.create!(syncable: accounts(:depository))
|
||||
sync.start!
|
||||
|
||||
sync.fail_for_retry_exhaustion!("rate limited too many times")
|
||||
|
||||
sync.reload
|
||||
assert_equal "failed", sync.status
|
||||
assert_equal "rate limited too many times", sync.error
|
||||
assert_not_nil sync.failed_at
|
||||
end
|
||||
|
||||
test "can run nested syncs that alert the parent when complete" do
|
||||
family = families(:dylan_family)
|
||||
plaid_item = plaid_items(:one)
|
||||
|
||||
Reference in New Issue
Block a user