-
Notifications
You must be signed in to change notification settings - Fork 96
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
chore(TransactionFeedV2): Add error handling to Transaction Feed V2 #6151
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6151 +/- ##
========================================
Coverage 88.76% 88.77%
========================================
Files 727 727
Lines 30776 30786 +10
Branches 5627 5631 +4
========================================
+ Hits 27319 27330 +11
- Misses 3259 3414 +155
+ Partials 198 42 -156
... and 68 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
@@ -7,3 +7,5 @@ export const apiReducersList = { | |||
} as const | |||
|
|||
export const apiMiddlewares = [transactionFeedV2Api.middleware] | |||
|
|||
export const apiReducersKeys = Object.keys(apiReducersList) |
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.
nit: Do we need this in more than one location? I couldn't quite see it from this PR.
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.
@jeanregisser Not really, just thought it might be a little more convenient to have api-related stuff exported from this file but I am totally fine with both approaches. I'll revert this one.
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.
We can keep it I guess, I was just wondering why it needed to change now in this PR.
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.
@jeanregisser initially I was also using apiReducersKeys
in the error logger to provide more precise info on what specific endpoint caused the error, but as I've figured that I can just pass the whole arg
- I removed the usage but kept apiReducersKeys
at the new place.
src/redux/api.ts
Outdated
export const rtkQueryErrorLoggerMiddleware: Middleware = | ||
(api: MiddlewareAPI) => (next) => (action) => { | ||
if (isRejectedWithValue(action)) { | ||
const errorMessage = | ||
'data' in action.error | ||
? (action.error.data as { message: string }).message | ||
: action.error.message | ||
|
||
Logger.error('RTK-Query', errorMessage || 'An error occured', action) | ||
api.dispatch(showError(ErrorMessages.FETCH_FAILED) as Action) | ||
} | ||
|
||
return next(action) | ||
} |
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.
Ah, we don't really want this generic error message anymore at this level.
Could we move it to be at the component level instead?
We now usually prefer showing inline errors, instead of the red banner at the top.
To avoid showing them from background tasks we have in the app, which could show up at inappropriate times (e.g. the user navigated to another screen, so the red banner is not directly relevant for something that's in the TX feed).
FETCH_FAILED
is really just used for the TX feed. And we should probably rename it.
I know moving it to the component won't change the fact that it could still trigger at inappropriate times.
But at least we can update the behavior later from the component.
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.
@jeanregisser Gotcha, I will adjust this to the new desirable approach.
It seems like queryHelper
only uses red banner for error. Could you please point me at the example with the inline error?
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.
What I meant is to control the error behavior from the component.
i.e. dispatch from the component instead of a generic error hander.
We can't yet switch to an inline error as we first need approved designs for that.
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.
Ah, got it. I'll move it to the component.
@jeanregisser updated |
@@ -39,6 +42,7 @@ type PaginatedData = { | |||
// Query poll interval | |||
const POLL_INTERVAL_MS = 10000 // 10 sec | |||
const FIRST_PAGE_TIMESTAMP = 0 | |||
const LOGGER_TAG = 'transactions/feed/TransactionFeedV2' |
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.
nit: can just call this TAG
, since it's only ever used for logging purposes anyways (and matches the naming convention we typically use)
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.
@jophish sure! I'll address this in the follow-up PR.
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.
nit: what's the problem with doing it here, since it's this PR that introduces it?
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.
@jeanregisser no problem with doing it here. I thought this should be a small enough change that it can be addressed within the next PR that I was already working on so there's less potential back-and-forth with rebasing all the follow-up PRs. But you're right, it makes sense to make the change here if this change is purely related to this PRs goal.
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.
@jeanregisser updated
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.
🚀
@@ -39,6 +42,7 @@ type PaginatedData = { | |||
// Query poll interval | |||
const POLL_INTERVAL_MS = 10000 // 10 sec | |||
const FIRST_PAGE_TIMESTAMP = 0 | |||
const LOGGER_TAG = 'transactions/feed/TransactionFeedV2' |
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.
nit: what's the problem with doing it here, since it's this PR that introduces it?
…6151) ### Description 5th PR for RET-1207. Adds error handling middleware as per [the docs](https://redux-toolkit.js.org/rtk-query/usage/error-handling) and also copies the same logic of error handling from [queryHelper](https://github.com/valora-inc/wallet/blob/main/src/transactions/feed/queryHelper.ts). ### Test plan Eveything works as before. ### Related issues - Relates to RET-1207 ### Backwards compatibility Yes ### Network scalability If a new NetworkId and/or Network are added in the future, the changes in this PR will: - [x] Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)
Description
5th PR for RET-1207. Adds error handling middleware as per the docs and also copies the same logic of error handling from queryHelper.
Test plan
Eveything works as before.
Related issues
Backwards compatibility
Yes
Network scalability
If a new NetworkId and/or Network are added in the future, the changes in this PR will: