Fix sentry inner crash and have watermelon report in which table it cannot update records with pending changes

This commit is contained in:
Elias Nahum
2023-01-07 12:49:48 +02:00
parent 68ec90df90
commit 977bcd2b42
4 changed files with 15 additions and 20 deletions

View File

@@ -436,7 +436,7 @@ export async function fetchPostsBefore(serverUrl: string, channelId: string, pos
await operator.batchRecords(models);
} catch (error) {
logError('FETCH AUTHORS ERROR', error);
logError('FETCH POSTS BEFORE ERROR', error);
}
}

View File

@@ -16,7 +16,6 @@ import {
captureException,
captureJSException,
initializeSentry,
LOGGER_NATIVE,
} from '@utils/sentry';
import {logWarning} from './log';
@@ -31,7 +30,7 @@ class JavascriptAndNativeErrorHandler {
nativeErrorHandler = (e: string) => {
logWarning('Handling native error ' + e);
captureException(e, LOGGER_NATIVE);
captureException(e);
};
errorHandler = (e: Error | ClientError, isFatal: boolean) => {

View File

@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import {Database} from '@nozbe/watermelondb';
import Sentry from '@sentry/react-native';
import {Breadcrumb, Event} from '@sentry/types';
import {Platform} from 'react-native';
import {Navigation} from 'react-native-navigation';
@@ -17,22 +18,12 @@ import {logError, logWarning} from './log';
export const BREADCRUMB_UNCAUGHT_APP_ERROR = 'uncaught-app-error';
export const BREADCRUMB_UNCAUGHT_NON_ERROR = 'uncaught-non-error';
export const LOGGER_EXTENSION = 'extension';
export const LOGGER_JAVASCRIPT = 'javascript';
export const LOGGER_JAVASCRIPT_WARNING = 'javascript_warning';
export const LOGGER_NATIVE = 'native';
let Sentry: any;
export function initializeSentry() {
if (!Config.SentryEnabled) {
return;
}
if (!Sentry) {
Sentry = require('@sentry/react-native');
}
const dsn = getDsn();
if (!dsn) {
@@ -81,16 +72,16 @@ function getDsn() {
return '';
}
export function captureException(error: Error | string, logger: string) {
export function captureException(error: Error | string) {
if (!Config.SentryEnabled) {
return;
}
if (!error || !logger) {
logWarning('captureException called with missing arguments', error, logger);
if (!error) {
logWarning('captureException called with missing arguments', error);
return;
}
Sentry.captureException(error, {logger});
Sentry.captureException(error);
}
export function captureJSException(error: Error | ClientError, isFatal: boolean) {
@@ -106,7 +97,7 @@ export function captureJSException(error: Error | ClientError, isFatal: boolean)
if (error instanceof ClientError) {
captureClientErrorAsBreadcrumb(error, isFatal);
} else {
captureException(error, LOGGER_JAVASCRIPT);
captureException(error);
}
}

View File

@@ -27,10 +27,10 @@ index 1a7c99e..0cb7b87 100644
public markAsDeleted(): Promise<void>
diff --git a/node_modules/@nozbe/watermelondb/Model/index.js b/node_modules/@nozbe/watermelondb/Model/index.js
index 075a047..75e5936 100644
index 075a047..5a1604d 100644
--- a/node_modules/@nozbe/watermelondb/Model/index.js
+++ b/node_modules/@nozbe/watermelondb/Model/index.js
@@ -78,6 +78,18 @@ var Model = /*#__PURE__*/function () {
@@ -78,10 +78,22 @@ var Model = /*#__PURE__*/function () {
// database.batch()
;
@@ -49,6 +49,11 @@ index 075a047..75e5936 100644
_proto.prepareUpdate = function prepareUpdate(recordUpdater = _noop.default) {
var _this = this;
- (0, _invariant.default)(!this._preparedState, "Cannot update a record with pending changes");
+ (0, _invariant.default)(!this._preparedState, "Cannot update a record with pending changes in table " + _this.table);
this.__ensureNotDisposable("Model.prepareUpdate()");
@@ -92,6 +104,7 @@ var Model = /*#__PURE__*/function () {
} // Perform updates