Skip to content

Commit

Permalink
fix: increased timeouts system wide
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed May 2, 2024
1 parent 226db06 commit 0fdf6d8
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 39 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ async function processEvent(ctx, event) {
});
if (!user) throw new Error('User did not exist for customer');
// artificially wait 5s for refund to process
await delay(ms('5s'));
await delay(ms('15s'));
//
// NOTE: this re-uses the payment intent mapper that is also used
// in the job for `sync-stripe-payments` which syncs payments
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/web/my-account/list-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const getLogsCsv = require('#helpers/get-logs-csv');
const parseRootDomain = require('#helpers/parse-root-domain');
const { Aliases, Logs } = require('#models');

const THIRTY_SECONDS = ms('30s');
const SIXTY_SECONDS = ms('60s');

// eslint-disable-next-line complexity
async function listLogs(ctx) {
Expand Down Expand Up @@ -398,9 +398,9 @@ async function listLogs(ctx) {
.skip(ctx.paginate.skip)
.sort(ctx.query.sort || '-created_at')
.lean()
.maxTimeMS(THIRTY_SECONDS)
.maxTimeMS(SIXTY_SECONDS)
.exec(),
Logs.countDocuments(query).maxTimeMS(THIRTY_SECONDS)
Logs.countDocuments(query).maxTimeMS(SIXTY_SECONDS)
]);
ctx.state.logs = logs;
ctx.state.itemCount = itemCount;
Expand Down
2 changes: 1 addition & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const config = {
removedEmailDomain: env.REMOVED_EMAIL_DOMAIN,

// SQLite busy_timeout value (how long we should wait for locking too)
busyTimeout: ms('10s'),
busyTimeout: ms('15s'),

// server
env: env.NODE_ENV.toLowerCase(),
Expand Down
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ function pug() {
}

async function img() {
if (!imagemin) await pWaitFor(() => Boolean(imagemin), { timeout: ms('5s') });
if (!imagemin)
await pWaitFor(() => Boolean(imagemin), { timeout: ms('15s') });
let stream = src('assets/img/**/*', {
base: config.assetsBase,
since: lastRun(img)
Expand Down
2 changes: 1 addition & 1 deletion helpers/create-tangerine.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function createTangerine(
if (!options || typeof options !== 'object')
options = {
// speeds up tests x2 if any DNS errors detected
timeout: env.NODE_ENV === 'production' ? 5000 : 2500,
timeout: env.NODE_ENV === 'production' ? 10000 : 5000,
tries: env.NODE_ENV === 'production' ? 4 : 2,
// use Cloudflare first then Google as a fallback in round-robin approach
servers: new Set(['1.1.1.1', '1.0.0.1', '8.8.8.8', '8.8.4.4']),
Expand Down
2 changes: 1 addition & 1 deletion helpers/create-websocket-as-promised.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function createWebSocketAsPromised(options = {}) {
// <https://github.com/vitalets/websocket-as-promised/issues/2#issuecomment-618241047>
wsp._interval = setInterval(() => {
if (wsp.isOpened) wsp.send('ping');
}, ms('30s'));
}, ms('60s'));

wsp.onClose.addListener(
() => {
Expand Down
6 changes: 3 additions & 3 deletions helpers/get-database.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ async function getDatabase(
try {
if (lock) await releaseLock(instance, db, lock);
} catch (err) {
logger.fatal(err, { alias, session });
logger.debug(err, { alias, session });
}

// if alias db size was 0 then we should update it
Expand All @@ -693,7 +693,7 @@ async function getDatabase(
if (storageUsed === 0) {
const size = await instance.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: alias.id
});
logger.debug('updating size', { size, alias, session });
Expand Down Expand Up @@ -741,7 +741,7 @@ function retryGetDatabase(...args) {
},
{
retries: 2,
minTimeout: ms('5s'),
minTimeout: ms('15s'),
onFailedAttempt(err) {
if (err.code === 'SQLITE_BUSY' || err.code === 'SQLITE_LOCKED') return;
if (isTimeoutError(err)) return;
Expand Down
2 changes: 1 addition & 1 deletion helpers/imap/on-append.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ async function onAppend(path, flags, date, raw, session, fn) {
try {
const size = await this.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: session.user.alias_id
});
this.logger.debug('size updated', size);
Expand Down
2 changes: 1 addition & 1 deletion helpers/imap/on-copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ async function onCopy(connection, mailboxId, update, session, fn) {
try {
await this.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: session.user.alias_id
});
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion helpers/imap/on-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async function onCreate(path, session, fn) {
try {
await this.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: session.user.alias_id
});
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion helpers/imap/on-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async function onDelete(path, session, fn) {
try {
await this.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: session.user.alias_id
});
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion helpers/imap/on-expunge.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ async function onExpunge(mailboxId, update, session, fn) {
try {
await this.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: session.user.alias_id,
lock
});
Expand Down
2 changes: 1 addition & 1 deletion helpers/imap/on-move.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ async function onMove(mailboxId, update, session, fn) {
try {
await this.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: session.user.alias_id,
lock
});
Expand Down
2 changes: 1 addition & 1 deletion helpers/imap/on-rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async function onRename(path, newPath, session, fn) {
try {
await this.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: session.user.alias_id
});
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion helpers/imap/on-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ async function onStore(mailboxId, update, session, fn) {
try {
await this.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: session.user.alias_id
});
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion helpers/lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function acquireLock(instance, db) {

if (!id) throw new TypeError('No alias ID or DB name found');

const lock = await instance.lock.waitAcquireLock(id, ms('15s'), ms('30s'));
const lock = await instance.lock.waitAcquireLock(id, ms('30s'), ms('60s'));

if (!lock.success)
throw new IMAPError(i18n.translate('IMAP_WRITE_LOCK_FAILED'));
Expand Down
12 changes: 6 additions & 6 deletions helpers/parse-payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ async function parsePayload(data, ws) {
// eslint-disable-next-line no-await-in-loop
await this.wsp.request.call(this, {
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: payload.session.user.alias_id,
lock: payload?.lock
});
Expand Down Expand Up @@ -1122,7 +1122,7 @@ async function parsePayload(data, ws) {
} catch {}
},
multiArgs: true,
timeout: ms('5s')
timeout: ms('15s')
});

const user = JSON.parse(response);
Expand Down Expand Up @@ -1350,7 +1350,7 @@ async function parsePayload(data, ws) {
try {
await this.wsp.request.call(this, {
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: alias.id,
lock: payload?.lock
});
Expand Down Expand Up @@ -1452,7 +1452,7 @@ async function parsePayload(data, ws) {
try {
await this.wsp.request.call(this, {
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: payload.session.user.alias_id,
lock: payload?.lock
});
Expand Down Expand Up @@ -1817,7 +1817,7 @@ async function parsePayload(data, ws) {
try {
await this.wsp.request.call(this, {
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: payload.session.user.alias_id,
lock: payload?.lock
});
Expand Down Expand Up @@ -1885,7 +1885,7 @@ async function parsePayload(data, ws) {
try {
await this.wsp.request.call(this, {
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: payload.session.user.alias_id,
lock
});
Expand Down
10 changes: 6 additions & 4 deletions helpers/process-email.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,12 +817,14 @@ async function processEmail({ email, port = 25, resolver, client }) {
wkd._fetch = (url) => {
return fetch(url, {
signal: AbortSignal.timeout(
config.env === 'test' ? ms('2s') : ms('5s')
config.env === 'test' ? ms('2s') : ms('30s')
),
dispatcher: new Agent({
headersTimeout: config.env === 'test' ? ms('2s') : ms('5s'),
connectTimeout: config.env === 'test' ? ms('2s') : ms('5s'),
bodyTimeout: config.env === 'test' ? ms('2s') : ms('5s'),
headersTimeout:
config.env === 'test' ? ms('2s') : ms('30s'),
connectTimeout:
config.env === 'test' ? ms('2s') : ms('30s'),
bodyTimeout: config.env === 'test' ? ms('2s') : ms('30s'),
connect: {
lookup(hostname, options, fn) {
resolver
Expand Down
2 changes: 1 addition & 1 deletion helpers/retry-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RetryClient extends undici.Client {
super(opts);

const timeout =
typeof opts?.timeout === 'number' ? opts.timeout : ms('30s');
typeof opts?.timeout === 'number' ? opts.timeout : ms('60s');
const retries = typeof opts?.retries === 'number' ? opts.retries : 3;

// exponential retry backoff (2, 4, 8)
Expand Down
4 changes: 2 additions & 2 deletions jobs/cleanup-sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ const mountDir = config.env === 'production' ? '/mnt' : tmpdir;
} catch {}
},
multiArgs: true,
timeout: ms('5s')
timeout: ms('10s')
});
const user = JSON.parse(response);
if (typeof user.password !== 'string') {
Expand Down Expand Up @@ -238,7 +238,7 @@ const mountDir = config.env === 'production' ? '/mnt' : tmpdir;
await wsp.request(
{
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: id
},
0
Expand Down
2 changes: 1 addition & 1 deletion routes/web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ router
}

if (!parseMMD)
await pWaitFor(() => Boolean(parseMMD), { timeout: ms('5s') });
await pWaitFor(() => Boolean(parseMMD), { timeout: ms('15s') });

browser = await puppeteer.launch();
const svg = await parseMMD(browser, code, 'png', {
Expand Down
10 changes: 5 additions & 5 deletions test/imap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ test('onGetQuotaRoot', async (t) => {
await delay(ms('1s'));
await t.context.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: alias.id
});

Expand Down Expand Up @@ -907,7 +907,7 @@ test('onGetQuotaRoot', async (t) => {
await delay(ms('1s'));
await t.context.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: alias.id
});
const storageUsed = await Aliases.getStorageUsed(alias);
Expand Down Expand Up @@ -968,7 +968,7 @@ ZXhhbXBsZQo=
await delay(ms('1s'));
await t.context.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: alias.id
});
// const message = await Messages.findOne(t.context.imap, session, {
Expand All @@ -994,7 +994,7 @@ test('onGetQuota', async (t) => {
await delay(ms('1s'));
await t.context.wsp.request({
action: 'size',
timeout: ms('5s'),
timeout: ms('15s'),
alias_id: t.context.alias.id
});
const quota = await t.context.imapFlow.getQuota();
Expand Down Expand Up @@ -1179,7 +1179,7 @@ ZXhhbXBsZQo=

t.true(res);

if (!data) await pWaitFor(() => Boolean(data), { timeout: ms('5s') });
if (!data) await pWaitFor(() => Boolean(data), { timeout: ms('15s') });

t.is(data.path, 'expunge');
t.is(data.vanished, false);
Expand Down

0 comments on commit 0fdf6d8

Please sign in to comment.