-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[STRATCONN-5399]-Handles refresh token retry for multistatus responses #2674
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2674 +/- ##
==========================================
+ Coverage 78.47% 78.91% +0.44%
==========================================
Files 1032 1085 +53
Lines 18590 21252 +2662
Branches 3521 4257 +736
==========================================
+ Hits 14588 16772 +2184
- Misses 2825 3297 +472
- Partials 1177 1183 +6 ☔ View full report in Codecov by Sentry. |
1eff09d
to
2b4f95c
Compare
2b4f95c
to
57b6f4f
Compare
@@ -901,7 +901,7 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> { | |||
return result | |||
} | |||
|
|||
const onFailedAttempt = async (error: ResponseError & HTTPError) => { | |||
const onFailedAttempt = async (error: ResponseError | HTTPError) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error can either be ResponeError or HTTPError. It can never be a mix of both.
} | ||
return true | ||
} | ||
return await retry<Result[]>(run, { retries: MAX_ATTEMPTS, onFailedAttempt, shouldRetry }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another approach I could have taken is to throw an exception if any of the events failed with 401 error and re-use the existing flow. However, that means we would end up reporting other 400 errors as 401 as well. Therefore, decided to go ahead with this approach of intentionally handling multistatus response. Open to any other thoughts.
This PR handles 401 refresh token retries for multistatus responses. Previously, we threw 401 exception for refresh token retries. However, for handling multistatus, developers now return a
MultistatusResponse
object fromperformBatch
block. This PR ensures that if any of the events in multistatus response has 401 status, the batch will be retried with new refresh token for oauth enabled destinations.Related but not dependent - https://github.com/segmentio/integrations/pull/3079
Testing
Testing completed successfully in staging - Test Doc