mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-23 23:54:13 +08:00
Retry metadata transfer for reminders, see if it fixes Sentry 363208698
This commit is contained in:
parent
438705c9dc
commit
d50d17d63f
3 changed files with 17 additions and 3 deletions
|
@ -80,9 +80,15 @@ export async function updateDraftReminderMetadata(draftSession, metadataValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function transferReminderMetadataFromDraftToThread({ accountId, headerMessageId }) {
|
export async function transferReminderMetadataFromDraftToThread({ accountId, headerMessageId }) {
|
||||||
const message = await DatabaseStore.findBy(Message, { accountId, headerMessageId });
|
let message = await DatabaseStore.findBy(Message, { accountId, headerMessageId });
|
||||||
if (!message) {
|
if (!message) {
|
||||||
throw new Error('SendReminders: Could not find message to update');
|
// The task has just completed, wait a moment to see if the message appears. Testing to
|
||||||
|
// see whether this resolves https://sentry.io/foundry-376-llc/mailspring/issues/363208698/
|
||||||
|
await Promise.delay(1500);
|
||||||
|
message = await DatabaseStore.findBy(Message, { accountId, headerMessageId });
|
||||||
|
if (!message) {
|
||||||
|
throw new Error('SendReminders: Could not find message to update');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const metadata = message.metadataForPluginId(PLUGIN_ID) || {};
|
const metadata = message.metadataForPluginId(PLUGIN_ID) || {};
|
||||||
|
@ -91,6 +97,9 @@ export async function transferReminderMetadataFromDraftToThread({ accountId, hea
|
||||||
}
|
}
|
||||||
|
|
||||||
const thread = await DatabaseStore.find(Thread, message.threadId);
|
const thread = await DatabaseStore.find(Thread, message.threadId);
|
||||||
|
if (!thread) {
|
||||||
|
throw new Error('SendReminders: Could not find thread to update');
|
||||||
|
}
|
||||||
updateReminderMetadata(thread, {
|
updateReminderMetadata(thread, {
|
||||||
expiration: metadata.expiration,
|
expiration: metadata.expiration,
|
||||||
sentHeaderMessageId: metadata.sentHeaderMessageId,
|
sentHeaderMessageId: metadata.sentHeaderMessageId,
|
||||||
|
|
|
@ -284,7 +284,7 @@ class DatabaseStore extends MailspringStore {
|
||||||
// We don't want to unnecessarily defer and delay every single query,
|
// We don't want to unnecessarily defer and delay every single query,
|
||||||
// so we only set the timer when we are actually backing off for a
|
// so we only set the timer when we are actually backing off for a
|
||||||
// retry.
|
// retry.
|
||||||
await new Promise(resolve => setTimeout(resolve, scheduler.currentDelay()));
|
await Promise.delay(scheduler.currentDelay());
|
||||||
}
|
}
|
||||||
|
|
||||||
let stmt = this._preparedStatementCache.get(query);
|
let stmt = this._preparedStatementCache.get(query);
|
||||||
|
|
|
@ -112,6 +112,10 @@ async function each(items, fn) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function delay(ms) {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
}
|
||||||
|
|
||||||
function props(obj) {
|
function props(obj) {
|
||||||
const awaitables = [];
|
const awaitables = [];
|
||||||
const keys = Object.keys(obj);
|
const keys = Object.keys(obj);
|
||||||
|
@ -149,6 +153,7 @@ global.Promise.prototype.isResolved = isResolved;
|
||||||
global.Promise.prototype.isRejected = isRejected;
|
global.Promise.prototype.isRejected = isRejected;
|
||||||
|
|
||||||
global.Promise.each = each;
|
global.Promise.each = each;
|
||||||
|
global.Promise.delay = delay;
|
||||||
global.Promise.props = props;
|
global.Promise.props = props;
|
||||||
global.Promise.promisify = promisify;
|
global.Promise.promisify = promisify;
|
||||||
global.Promise.promisifyAll = promisifyAll;
|
global.Promise.promisifyAll = promisifyAll;
|
||||||
|
|
Loading…
Reference in a new issue