Better database errors in worker thread
This commit is contained in:
parent
2cbc1a82b2
commit
6143888f6c
3 changed files with 21 additions and 8 deletions
|
@ -117,7 +117,6 @@ import { load as loadLocale } from './locale';
|
||||||
import type { LoggerType } from '../ts/types/Logging';
|
import type { LoggerType } from '../ts/types/Logging';
|
||||||
import { HourCyclePreference } from '../ts/types/I18N';
|
import { HourCyclePreference } from '../ts/types/I18N';
|
||||||
import { ScreenShareStatus } from '../ts/types/Calling';
|
import { ScreenShareStatus } from '../ts/types/Calling';
|
||||||
import { DBVersionFromFutureError } from '../ts/sql/migrations';
|
|
||||||
import type { ParsedSignalRoute } from '../ts/util/signalRoutes';
|
import type { ParsedSignalRoute } from '../ts/util/signalRoutes';
|
||||||
import { parseSignalRoute } from '../ts/util/signalRoutes';
|
import { parseSignalRoute } from '../ts/util/signalRoutes';
|
||||||
import * as dns from '../ts/util/dns';
|
import * as dns from '../ts/util/dns';
|
||||||
|
@ -1800,7 +1799,9 @@ const onDatabaseError = async (error: Error) => {
|
||||||
const copyErrorAndQuitButtonIndex = 0;
|
const copyErrorAndQuitButtonIndex = 0;
|
||||||
const SIGNAL_SUPPORT_LINK = 'https://support.signal.org/error';
|
const SIGNAL_SUPPORT_LINK = 'https://support.signal.org/error';
|
||||||
|
|
||||||
if (error instanceof DBVersionFromFutureError) {
|
// Note that this error is thrown by the worker process and thus instanceof
|
||||||
|
// check won't work.
|
||||||
|
if (error.name === 'DBVersionFromFutureError') {
|
||||||
// If the DB version is too new, the user likely opened an older version of Signal,
|
// If the DB version is too new, the user likely opened an older version of Signal,
|
||||||
// and they would almost never want to delete their data as a result, so we don't show
|
// and they would almost never want to delete their data as a result, so we don't show
|
||||||
// that option
|
// that option
|
||||||
|
|
|
@ -70,7 +70,13 @@ export type WrappedWorkerResponse =
|
||||||
| Readonly<{
|
| Readonly<{
|
||||||
type: 'response';
|
type: 'response';
|
||||||
seq: number;
|
seq: number;
|
||||||
error: string | undefined;
|
error:
|
||||||
|
| Readonly<{
|
||||||
|
name: string;
|
||||||
|
message: string;
|
||||||
|
stack: string | undefined;
|
||||||
|
}>
|
||||||
|
| undefined;
|
||||||
errorKind: SqliteErrorKind | undefined;
|
errorKind: SqliteErrorKind | undefined;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
response: any;
|
response: any;
|
||||||
|
@ -382,7 +388,9 @@ export class MainSQL {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
const errorObj = new Error(error);
|
const errorObj = new Error(error.message);
|
||||||
|
errorObj.stack = error.stack;
|
||||||
|
errorObj.name = error.name;
|
||||||
this.onError(errorKind ?? SqliteErrorKind.Unknown, errorObj);
|
this.onError(errorKind ?? SqliteErrorKind.Unknown, errorObj);
|
||||||
|
|
||||||
pair.reject(errorObj);
|
pair.reject(errorObj);
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
import { parentPort } from 'worker_threads';
|
import { parentPort } from 'worker_threads';
|
||||||
|
|
||||||
import type { LoggerType } from '../types/Logging';
|
import type { LoggerType } from '../types/Logging';
|
||||||
import * as Errors from '../types/errors';
|
|
||||||
import type {
|
import type {
|
||||||
WrappedWorkerRequest,
|
WrappedWorkerRequest,
|
||||||
WrappedWorkerResponse,
|
WrappedWorkerResponse,
|
||||||
|
@ -23,10 +22,8 @@ const port = parentPort;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function respond(seq: number, error: Error | undefined, response?: any) {
|
function respond(seq: number, error: Error | undefined, response?: any) {
|
||||||
let errorKind: SqliteErrorKind | undefined;
|
let errorKind: SqliteErrorKind | undefined;
|
||||||
let errorString: string | undefined;
|
|
||||||
if (error !== undefined) {
|
if (error !== undefined) {
|
||||||
errorKind = parseSqliteError(error);
|
errorKind = parseSqliteError(error);
|
||||||
errorString = Errors.toLogFormat(error);
|
|
||||||
|
|
||||||
if (errorKind === SqliteErrorKind.Corrupted && db != null) {
|
if (errorKind === SqliteErrorKind.Corrupted && db != null) {
|
||||||
DataWriter.runCorruptionChecks(db);
|
DataWriter.runCorruptionChecks(db);
|
||||||
|
@ -36,7 +33,14 @@ function respond(seq: number, error: Error | undefined, response?: any) {
|
||||||
const wrappedResponse: WrappedWorkerResponse = {
|
const wrappedResponse: WrappedWorkerResponse = {
|
||||||
type: 'response',
|
type: 'response',
|
||||||
seq,
|
seq,
|
||||||
error: errorString,
|
error:
|
||||||
|
error == null
|
||||||
|
? undefined
|
||||||
|
: {
|
||||||
|
name: error.name,
|
||||||
|
message: error.message,
|
||||||
|
stack: error.stack,
|
||||||
|
},
|
||||||
errorKind,
|
errorKind,
|
||||||
response,
|
response,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue