Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/libs/actions/OnyxUpdates.ts
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';
Expand Down Expand Up @@ -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.
Comment thread
MrMuzyk marked this conversation as resolved.
// 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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (String(error).includes('[SqlExecutionError]') && request.command === READ_COMMANDS.OPEN_UNREPORTED_EXPENSES_PAGE && response.onyxData !== undefined) {
if (String(error).includes('[SqlExecutionError]') && response.onyxData !== undefined) {

How about making temp solution generic to avoid similar issues at other places, as sqlException is logged at multiple places?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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)
Expand Down
Loading