-
Notifications
You must be signed in to change notification settings - Fork 4k
fix: Retry OpenUnreportedExpensesPage on SQL error #70789
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
Changes from all commits
6246ddf
638355a
874b572
406a62b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||
| import type {OnyxUpdate} from 'react-native-onyx'; | ||||||
| import Onyx from 'react-native-onyx'; | ||||||
| import type {Merge} from 'type-fest'; | ||||||
| import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; | ||||||
| import {READ_COMMANDS, SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; | ||||||
| import Log from '@libs/Log'; | ||||||
| import Performance from '@libs/Performance'; | ||||||
| import PusherUtils from '@libs/PusherUtils'; | ||||||
|
|
@@ -38,7 +38,19 @@ function applyHTTPSOnyxUpdates(request: Request, response: Response, lastUpdateI | |||||
| // First apply any onyx data updates that are being sent back from the API. We wait for this to complete and then | ||||||
| // apply successData or failureData. This ensures that we do not update any pending, loading, or other UI states contained | ||||||
| // in successData/failureData until after the component has received and API data. | ||||||
| const onyxDataUpdatePromise = response.onyxData ? updateHandler(response.onyxData) : Promise.resolve(); | ||||||
| const onyxDataUpdatePromise = response.onyxData | ||||||
| ? updateHandler(response.onyxData).catch((error: unknown) => { | ||||||
| // Sometimes we get a SQL error here if the previous queued write failed. In that case, we want to still apply the Onyx update | ||||||
| // This is temporary fix until we can identify what causes SQL errors. Ideally we would only like to catch errors here. | ||||||
| // Related issue - https://github.com/Expensify/App/issues/69808 | ||||||
| if (String(error).includes('[SqlExecutionError]') && request.command === READ_COMMANDS.OPEN_UNREPORTED_EXPENSES_PAGE && response.onyxData !== undefined) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
How about making temp solution generic to avoid similar issues at other places, as sqlException is logged at multiple places?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was considering it but it's hard to predict the affect this change will have. In different cases of SQL errors (and we know such exist) this might break the app and cause more errors. My idea was to start logging these, check how many and how often these errors come up and then react accordingly. |
||||||
| Log.warn(`${String(error)}, retrying Onyx update`); | ||||||
| return updateHandler(response.onyxData); | ||||||
| } | ||||||
| Log.warn(String(error)); | ||||||
| }) | ||||||
| : Promise.resolve(); | ||||||
|
|
||||||
| return onyxDataUpdatePromise | ||||||
| .then(() => { | ||||||
| // Handle the request's success/failure data (client-side data) | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.