Add p-queue timeouts; fix search crash; improve promise rejection logging

This commit is contained in:
Scott Nonnenberg 2020-09-18 13:40:41 -07:00 committed by Josh Perez
parent 9f9ce91a9c
commit bc3b61db1d
17 changed files with 54 additions and 26 deletions

View file

@ -14,9 +14,13 @@
// eslint-disable-next-line func-names
(async function() {
const eventHandlerQueue = new window.PQueue({ concurrency: 1 });
const eventHandlerQueue = new window.PQueue({
concurrency: 1,
timeout: 1000 * 60 * 2,
});
Whisper.deliveryReceiptQueue = new window.PQueue({
concurrency: 1,
timeout: 1000 * 60 * 2,
});
Whisper.deliveryReceiptQueue.pause();
Whisper.deliveryReceiptBatcher = window.Signal.Util.createBatcher({

View file

@ -142,7 +142,8 @@ window.onerror = (message, script, line, col, error) => {
};
window.addEventListener('unhandledrejection', rejectionEvent => {
window.log.error(
`Top-level unhandled promise rejection: ${rejectionEvent.reason}`
);
const error = rejectionEvent.reason;
const errorString =
error && error.stack ? error.stack : JSON.stringify(error);
window.log.error(`Top-level unhandled promise rejection: ${errorString}`);
});

View file

@ -225,8 +225,9 @@
getPropsForSearchResult() {
const sourceId = this.getContactId();
const from = this.findAndFormatContact(sourceId);
const convo = this.getConversation();
const to = this.findAndFormatContact(convo.get('id'));
const conversationId = this.get('conversationId');
const to = this.findAndFormatContact(conversationId);
return {
from,
@ -235,7 +236,7 @@
isSelected: this.isSelected,
id: this.id,
conversationId: this.get('conversationId'),
conversationId,
sentAt: this.get('sent_at'),
snippet: this.get('snippet'),
};

View file

@ -75,7 +75,7 @@ module.exports = {
let initialState = null;
let packsToDownload = null;
const downloadQueue = new Queue({ concurrency: 1 });
const downloadQueue = new Queue({ concurrency: 1, timeout: 1000 * 60 * 2 });
async function load() {
const [packs, recentStickers] = await Promise.all([
@ -336,6 +336,7 @@ async function removeEphemeralPack(packId) {
const paths = stickers.map(sticker => sticker.path);
await pMap(paths, Signal.Migrations.deleteTempFile, {
concurrency: 3,
timeout: 1000 * 60 * 2,
});
// Remove it from database in case it made it there
@ -429,7 +430,10 @@ async function downloadEphemeralPack(packId, packKey) {
await downloadStickerJob(coverProto);
// Then the rest
await pMap(nonCoverStickers, downloadStickerJob, { concurrency: 3 });
await pMap(nonCoverStickers, downloadStickerJob, {
concurrency: 3,
timeout: 1000 * 60 * 2,
});
} catch (error) {
// Because the user could install this pack while we are still downloading this
// ephemeral pack, we don't want to go change its status unless we're still in
@ -610,7 +614,10 @@ async function doDownloadStickerPack(packId, packKey, options = {}) {
await downloadStickerJob(coverProto);
// Then the rest
await pMap(nonCoverStickers, downloadStickerJob, { concurrency: 3 });
await pMap(nonCoverStickers, downloadStickerJob, {
concurrency: 3,
timeout: 1000 * 60 * 2,
});
// Allow for the user marking this pack as installed in the middle of our download;
// don't overwrite that status.
@ -724,6 +731,7 @@ async function deletePackReference(messageId, packId) {
await pMap(paths, Signal.Migrations.deleteSticker, {
concurrency: 3,
timeout: 1000 * 60 * 2,
});
}
@ -743,5 +751,6 @@ async function deletePack(packId) {
await pMap(paths, Signal.Migrations.deleteSticker, {
concurrency: 3,
timeout: 1000 * 60 * 2,
});
}