Improve error handling during group sends
This commit is contained in:
parent
f0a3735ca2
commit
991580a1ed
58 changed files with 299 additions and 324 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
import { getEnvironment, Environment } from '../environment';
|
||||
import * as log from '../logging/log';
|
||||
import * as Errors from '../types/errors';
|
||||
|
||||
/**
|
||||
* In production and beta, logs a warning and continues. For development it
|
||||
|
@ -15,7 +16,7 @@ export function softAssert(condition: unknown, message: string): void {
|
|||
}
|
||||
|
||||
const err = new Error(message);
|
||||
log.warn('softAssert failure:', err && err.stack ? err.stack : err);
|
||||
log.warn('softAssert failure:', Errors.toLogFormat(err));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +35,7 @@ export function assertDev(
|
|||
}
|
||||
throw err;
|
||||
}
|
||||
log.error('assert failure:', err && err.stack ? err.stack : err);
|
||||
log.error('assert failure:', Errors.toLogFormat(err));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@ import { getValue } from '../RemoteConfig';
|
|||
|
||||
import { parseIntOrThrow } from './parseIntOrThrow';
|
||||
import { scaleImageToLevel } from './scaleImageToLevel';
|
||||
import { isRecord } from './isRecord';
|
||||
import type { AttachmentType } from '../types/Attachment';
|
||||
import { canBeTranscoded } from '../types/Attachment';
|
||||
import type { LoggerType } from '../types/Logging';
|
||||
import * as MIME from '../types/MIME';
|
||||
import * as Errors from '../types/errors';
|
||||
|
||||
const MEBIBYTE = 1024 * 1024;
|
||||
const DEFAULT_MAX = 100 * MEBIBYTE;
|
||||
|
@ -87,8 +87,7 @@ export async function autoOrientJPEG(
|
|||
|
||||
return xcodedAttachment;
|
||||
} catch (error: unknown) {
|
||||
const errorString =
|
||||
isRecord(error) && 'stack' in error ? error.stack : error;
|
||||
const errorString = Errors.toLogFormat(error);
|
||||
logger.error(
|
||||
'autoOrientJPEG: Failed to rotate/scale attachment',
|
||||
errorString
|
||||
|
|
|
@ -14,6 +14,7 @@ import type {
|
|||
DefaultConversationColorType,
|
||||
} from '../types/Colors';
|
||||
import { DEFAULT_CONVERSATION_COLOR } from '../types/Colors';
|
||||
import * as Errors from '../types/errors';
|
||||
import * as Stickers from '../types/Stickers';
|
||||
import type { SystemTraySetting } from '../types/SystemTraySetting';
|
||||
import { parseSystemTraySetting } from '../types/SystemTraySetting';
|
||||
|
@ -453,7 +454,7 @@ export function createIPCEvents(
|
|||
window.isShowingModal = false;
|
||||
log.error(
|
||||
'showStickerPack: Ran into an error!',
|
||||
error && error.stack ? error.stack : error
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
const errorView = new ReactWrapperView({
|
||||
className: 'error-modal-wrapper',
|
||||
|
@ -483,7 +484,7 @@ export function createIPCEvents(
|
|||
} catch (error) {
|
||||
log.error(
|
||||
'showGroupViaLink: Ran into an error!',
|
||||
error && error.stack ? error.stack : error
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
const errorView = new ReactWrapperView({
|
||||
className: 'error-modal-wrapper',
|
||||
|
|
|
@ -102,7 +102,7 @@ export async function onRetryRequest(event: RetryRequestEvent): Promise<void> {
|
|||
} catch (error) {
|
||||
log.warn(
|
||||
`onRetryRequest/${logId}: Failed to parse integer from desktop.retryRespondMaxAge feature flag`,
|
||||
error && error.stack ? error.stack : error
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ async function sendDistributionMessageOrNullMessage(
|
|||
} catch (error) {
|
||||
log.error(
|
||||
`sendDistributionMessageOrNullMessage/${logId}: Failed to send sender key distribution message`,
|
||||
error && error.stack ? error.stack : error
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ async function requestResend(decryptionError: DecryptionErrorEventData) {
|
|||
} catch (error) {
|
||||
log.error(
|
||||
`requestResend/${logId}: Failed to send retry request, failing over to automatic reset`,
|
||||
error && error.stack ? error.stack : error
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
startAutomaticSessionReset(decryptionError);
|
||||
return;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
import { Environment, getEnvironment } from '../environment';
|
||||
import { isInPast } from './timestamp';
|
||||
import * as log from '../logging/log';
|
||||
import * as Errors from '../types/errors';
|
||||
|
||||
const ONE_DAY_MS = 86400 * 1000;
|
||||
const NINETY_ONE_DAYS = 91 * ONE_DAY_MS;
|
||||
|
@ -18,7 +19,7 @@ export function hasExpired(): boolean {
|
|||
log.info('Build expires: ', new Date(buildExpiration).toISOString());
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('Error retrieving build expiration date', e.stack);
|
||||
log.error('Error retrieving build expiration date', Errors.toLogFormat(e));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ const loadImageData = async (input: Input): Promise<ImageData> => {
|
|||
canvasOrError => {
|
||||
if (canvasOrError instanceof Event && canvasOrError.type === 'error') {
|
||||
const processError = new Error(
|
||||
'imageToBlurHash: Failed to process image'
|
||||
'imageToBlurHash: Failed to process image',
|
||||
{ cause: canvasOrError }
|
||||
);
|
||||
processError.originalError = canvasOrError;
|
||||
reject(processError);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import { ReactWrapperView } from '../views/ReactWrapperView';
|
|||
import { ErrorModal } from '../components/ErrorModal';
|
||||
import { ProgressModal } from '../components/ProgressModal';
|
||||
import * as log from '../logging/log';
|
||||
import * as Errors from '../types/errors';
|
||||
import { clearTimeoutIfNecessary } from './clearTimeoutIfNecessary';
|
||||
|
||||
export async function longRunningTaskWrapper<T>({
|
||||
|
@ -62,7 +63,7 @@ export async function longRunningTaskWrapper<T>({
|
|||
} catch (error) {
|
||||
log.error(
|
||||
`longRunningTaskWrapper/${idLog}: Error!`,
|
||||
error && error.stack ? error.stack : error
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
|
||||
clearTimeoutIfNecessary(progressTimeout);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
import { ipcRenderer } from 'electron';
|
||||
|
||||
import { strictAssert } from './assert';
|
||||
import * as Errors from '../types/errors';
|
||||
import type { UnwrapPromise } from '../types/Util';
|
||||
import type {
|
||||
IPCEventsValuesType,
|
||||
|
@ -104,11 +105,7 @@ export function installSetting(
|
|||
try {
|
||||
ipcRenderer.send('settings:response', seq, null, await getFn());
|
||||
} catch (error) {
|
||||
ipcRenderer.send(
|
||||
'settings:response',
|
||||
seq,
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
ipcRenderer.send('settings:response', seq, Errors.toLogFormat(error));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -132,11 +129,7 @@ export function installSetting(
|
|||
await setFn(value);
|
||||
ipcRenderer.send('settings:response', seq, null);
|
||||
} catch (error) {
|
||||
ipcRenderer.send(
|
||||
'settings:response',
|
||||
seq,
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
ipcRenderer.send('settings:response', seq, Errors.toLogFormat(error));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -152,11 +145,7 @@ export function installCallback<Name extends keyof IPCEventsCallbacksType>(
|
|||
try {
|
||||
ipcRenderer.send('settings:response', seq, null, await hook(...args));
|
||||
} catch (error) {
|
||||
ipcRenderer.send(
|
||||
'settings:response',
|
||||
seq,
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
ipcRenderer.send('settings:response', seq, Errors.toLogFormat(error));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import type {
|
|||
AttachmentDraftType,
|
||||
InMemoryAttachmentDraftType,
|
||||
} from '../types/Attachment';
|
||||
import * as Errors from '../types/errors';
|
||||
import { getMaximumAttachmentSize } from './attachments';
|
||||
import { AttachmentToastType } from '../types/AttachmentToastType';
|
||||
import { fileToBytes } from './fileToBytes';
|
||||
|
@ -105,7 +106,7 @@ export async function processAttachment(
|
|||
} catch (e) {
|
||||
log.error(
|
||||
`Was unable to generate thumbnail for fileType ${fileType}`,
|
||||
e && e.stack ? e.stack : e
|
||||
Errors.toLogFormat(e)
|
||||
);
|
||||
const data = await fileToBytes(file);
|
||||
attachment = {
|
||||
|
@ -125,7 +126,7 @@ export async function processAttachment(
|
|||
} catch (error) {
|
||||
log.error(
|
||||
'Error ensuring that image is properly sized:',
|
||||
error && error.stack ? error.stack : error
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
|
||||
throw error;
|
||||
|
|
|
@ -19,6 +19,7 @@ import type {
|
|||
MessageAttributesType,
|
||||
QuotedMessageType,
|
||||
} from '../model-types.d';
|
||||
import * as Errors from '../types/errors';
|
||||
import type { StickerType } from '../types/Stickers';
|
||||
import type { LinkPreviewType } from '../types/message/LinkPreviews';
|
||||
|
||||
|
@ -222,7 +223,7 @@ export async function queueAttachmentDownloads(
|
|||
} catch (error) {
|
||||
log.error(
|
||||
`Problem copying sticker (${packId}, ${stickerId}) to attachments:`,
|
||||
error && error.stack ? error.stack : error
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import { IMAGE_JPEG } from '../types/MIME';
|
|||
import { canvasToBlob } from './canvasToBlob';
|
||||
import { getValue } from '../RemoteConfig';
|
||||
import { parseNumber } from './libphonenumberUtil';
|
||||
import { isRecord } from './isRecord';
|
||||
|
||||
enum MediaQualityLevels {
|
||||
One = 1,
|
||||
|
@ -126,13 +125,10 @@ export async function scaleImageToLevel(
|
|||
throw new Error('image not a canvas');
|
||||
}
|
||||
({ image } = data);
|
||||
} catch (err) {
|
||||
const errorString = isRecord(err) && 'stack' in err ? err.stack : err;
|
||||
const error = new Error(
|
||||
'scaleImageToLevel: Failed to process image',
|
||||
errorString
|
||||
);
|
||||
error.originalError = err;
|
||||
} catch (cause) {
|
||||
const error = new Error('scaleImageToLevel: Failed to process image', {
|
||||
cause,
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import { differenceWith, omit, partition } from 'lodash';
|
|||
|
||||
import {
|
||||
ErrorCode,
|
||||
LibSignalErrorBase,
|
||||
groupEncrypt,
|
||||
ProtocolAddress,
|
||||
sealedSenderMultiRecipientEncrypt,
|
||||
|
@ -21,6 +22,7 @@ import {
|
|||
import { Address } from '../types/Address';
|
||||
import { QualifiedAddress } from '../types/QualifiedAddress';
|
||||
import { UUID } from '../types/UUID';
|
||||
import * as Errors from '../types/errors';
|
||||
import { getValue, isEnabled } from '../RemoteConfig';
|
||||
import type { UUIDStringType } from '../types/UUID';
|
||||
import { isRecord } from './isRecord';
|
||||
|
@ -216,7 +218,7 @@ export async function sendContentMessageToGroup({
|
|||
|
||||
log.error(
|
||||
`sendToGroup/${logId}: Sender Key send failed, logging, proceeding to normal send`,
|
||||
error && error.stack ? error.stack : error
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -581,7 +583,10 @@ export async function sendToGroupViaSenderKey(options: {
|
|||
recursionCount: recursionCount + 1,
|
||||
});
|
||||
}
|
||||
if (error.code === ErrorCode.InvalidRegistrationId && error.addr) {
|
||||
if (
|
||||
error instanceof LibSignalErrorBase &&
|
||||
error.code === ErrorCode.InvalidRegistrationId
|
||||
) {
|
||||
const address = error.addr as ProtocolAddress;
|
||||
const name = address.name();
|
||||
|
||||
|
@ -742,7 +747,7 @@ function getSenderKeyExpireDuration(): number {
|
|||
} catch (error) {
|
||||
log.warn(
|
||||
`getSenderKeyExpireDuration: Failed to parse integer. Using default of ${MAX_SENDER_KEY_EXPIRE_DURATION}.`,
|
||||
error && error.stack ? error.stack : error
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
return MAX_SENDER_KEY_EXPIRE_DURATION;
|
||||
}
|
||||
|
@ -753,7 +758,10 @@ export function _shouldFailSend(error: unknown, logId: string): boolean {
|
|||
log.error(`_shouldFailSend/${logId}: ${message}`);
|
||||
};
|
||||
|
||||
if (error instanceof Error && error.message.includes('untrusted identity')) {
|
||||
if (
|
||||
error instanceof LibSignalErrorBase &&
|
||||
error.code === ErrorCode.UntrustedIdentity
|
||||
) {
|
||||
logError("'untrusted identity' error, failing.");
|
||||
return true;
|
||||
}
|
||||
|
@ -1271,7 +1279,7 @@ async function fetchKeysForIdentifiers(
|
|||
} catch (error) {
|
||||
log.error(
|
||||
'fetchKeysForIdentifiers: Failed to fetch keys:',
|
||||
error && error.stack ? error.stack : error
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue