Skip to content
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: suppress "ConditionError" in Logger #6213

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sviderock
Copy link
Contributor

Description

This is not an actual error but rather a way for Redux Toolkit to signal that a thunk condition (most likely caused by RTK-Query) has evaluated to false and cancelled the thunk execution OR the thunk execution was aborted. As can be seen from the Redux Toolkit code – this is not an actual Error class instance but just a way of signalling the failed condition
necessary to execute the thunk.

For more context, please check out the following links:
https://stackoverflow.com/questions/69789058/what-does-this-error-mean-in-redux-toolkit
https://redux-toolkit.js.org/api/createAsyncThunk#options

Test plan

N/A

Related issues

N/A

Backwards compatibility

Yes

Network scalability

If a new NetworkId and/or Network are added in the future, the changes in this PR will:

  • Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)

* https://stackoverflow.com/questions/69789058/what-does-this-error-mean-in-redux-toolkit
* https://redux-toolkit.js.org/api/createAsyncThunk#options
*/
if (messages?.[0]?.error?.name === 'ConditionError') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case, I've ran a check in node_modules to ensure no other dependency is throwing ConditionError. The only library using is is Redux Toolkit and the only place where this particular error is thrown is in the only place in their codebase that I've linked there in the comment (first link).

So it is safe to assume that suppressing this error will not suppress any errors that we do not want to suppress.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of doing this in the logger saga instead?

wallet/src/redux/sagas.ts

Lines 77 to 101 in 34a9d38

function* loggerSaga() {
const devModeActive: boolean = yield* select(devModeSelector)
if (!devModeActive) {
return
}
yield* takeEvery('*', (action: UnknownAction) => {
if (
action?.type &&
(action.type.includes('IDENTITY/') || loggerPayloadBlocklist.includes(action.type))
) {
// Log only action type, but not the payload as it can have sensitive
// information or information that is not helpful for debugging. Excluding
// all IDENTITY/ actions because high likelyhood they contain PII and the
// blocklist may get out of date.
Logger.debug('redux/saga@logger', `${action.type} (payload not logged)`)
return
}
try {
Logger.debug('redux/saga@logger', action)
} catch (err) {
Logger.warn('redux/saga@logger', 'could not log action of type', action.type)
}
})
}

This way it's more targeted. And the logger doesn't need to know about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeanregisser I think it makes sense, will do!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeanregisser updated

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.92%. Comparing base (fd30a91) to head (1b17fe6).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/redux/sagas.ts 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6213      +/-   ##
==========================================
- Coverage   88.93%   88.92%   -0.01%     
==========================================
  Files         737      737              
  Lines       31370    31381      +11     
  Branches     5796     5805       +9     
==========================================
+ Hits        27898    27906       +8     
- Misses       3274     3431     +157     
+ Partials      198       44     -154     
Files with missing lines Coverage Δ
src/redux/sagas.ts 48.03% <0.00%> (-0.97%) ⬇️

... and 69 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd30a91...1b17fe6. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants