Add no-misused/floating-promises lint rule
This commit is contained in:
parent
1a68c3db62
commit
ed271d92ea
150 changed files with 1296 additions and 991 deletions
|
@ -13,6 +13,7 @@ import PQueue from 'p-queue';
|
|||
import { JobError } from '../../jobs/JobError';
|
||||
import { TestJobQueueStore } from './TestJobQueueStore';
|
||||
import { missingCaseError } from '../../util/missingCaseError';
|
||||
import { drop } from '../../util/drop';
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
|
||||
import { JobQueue } from '../../jobs/JobQueue';
|
||||
|
@ -51,7 +52,7 @@ describe('JobQueue', () => {
|
|||
assert.deepEqual(results, new Set());
|
||||
assert.isEmpty(store.storedJobs);
|
||||
|
||||
addQueue.streamJobs();
|
||||
drop(addQueue.streamJobs());
|
||||
|
||||
store.pauseStream('test add queue');
|
||||
const job1 = await addQueue.add({ a: 1, b: 2 });
|
||||
|
@ -85,7 +86,7 @@ describe('JobQueue', () => {
|
|||
async run(): Promise<void> {
|
||||
try {
|
||||
updateActiveJobCount(1);
|
||||
sleep(1);
|
||||
await sleep(1);
|
||||
} finally {
|
||||
updateActiveJobCount(-1);
|
||||
}
|
||||
|
@ -99,7 +100,7 @@ describe('JobQueue', () => {
|
|||
queueType: 'test queue',
|
||||
maxAttempts: 100,
|
||||
});
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
const createPromise1 = queue.add(1);
|
||||
const createPromise2 = queue.add(2);
|
||||
|
@ -153,7 +154,7 @@ describe('JobQueue', () => {
|
|||
queueType: 'test queue',
|
||||
maxAttempts: 100,
|
||||
});
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
const jobs = await Promise.all([
|
||||
queue.add(1),
|
||||
|
@ -193,8 +194,8 @@ describe('JobQueue', () => {
|
|||
store.pauseStream('test 1');
|
||||
store.pauseStream('test 2');
|
||||
|
||||
queue1.streamJobs();
|
||||
queue2.streamJobs();
|
||||
drop(queue1.streamJobs());
|
||||
drop(queue2.streamJobs());
|
||||
|
||||
await queue1.add('one');
|
||||
await queue2.add('A');
|
||||
|
@ -253,7 +254,7 @@ describe('JobQueue', () => {
|
|||
maxAttempts: 1,
|
||||
});
|
||||
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
const insert = sinon.stub().resolves();
|
||||
|
||||
|
@ -316,7 +317,7 @@ describe('JobQueue', () => {
|
|||
maxAttempts: 5,
|
||||
});
|
||||
|
||||
retryQueue.streamJobs();
|
||||
drop(retryQueue.streamJobs());
|
||||
|
||||
await (
|
||||
await retryQueue.add('foo')
|
||||
|
@ -371,7 +372,7 @@ describe('JobQueue', () => {
|
|||
maxAttempts: 6,
|
||||
});
|
||||
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
try {
|
||||
await (
|
||||
|
@ -418,7 +419,7 @@ describe('JobQueue', () => {
|
|||
logger: fakeLogger,
|
||||
});
|
||||
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
const job = await queue.add(1);
|
||||
await job.completion;
|
||||
|
@ -460,7 +461,7 @@ describe('JobQueue', () => {
|
|||
maxAttempts: 999,
|
||||
});
|
||||
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
const job = await queue.add('this will fail to parse');
|
||||
|
||||
|
@ -504,7 +505,7 @@ describe('JobQueue', () => {
|
|||
maxAttempts: 999,
|
||||
});
|
||||
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
(await queue.add('invalid')).completion.catch(noop);
|
||||
(await queue.add('invalid')).completion.catch(noop);
|
||||
|
@ -538,7 +539,7 @@ describe('JobQueue', () => {
|
|||
maxAttempts: 999,
|
||||
});
|
||||
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
await (await queue.add('invalid 1')).completion.catch(noop);
|
||||
await (await queue.add('invalid 2')).completion.catch(noop);
|
||||
|
@ -572,7 +573,7 @@ describe('JobQueue', () => {
|
|||
maxAttempts: 999,
|
||||
});
|
||||
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
const addPromise = queue.add(undefined);
|
||||
assert.isFalse(inserted);
|
||||
|
@ -606,7 +607,7 @@ describe('JobQueue', () => {
|
|||
maxAttempts: 999,
|
||||
});
|
||||
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
await (
|
||||
await queue.add(123)
|
||||
|
@ -639,7 +640,7 @@ describe('JobQueue', () => {
|
|||
maxAttempts: 999,
|
||||
});
|
||||
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
store.pauseStream('test queue');
|
||||
const job = await queue.add(undefined);
|
||||
|
@ -681,7 +682,7 @@ describe('JobQueue', () => {
|
|||
maxAttempts: 5,
|
||||
});
|
||||
|
||||
queue.streamJobs();
|
||||
drop(queue.streamJobs());
|
||||
|
||||
store.pauseStream('test queue');
|
||||
const job = await queue.add(undefined);
|
||||
|
@ -763,7 +764,7 @@ describe('JobQueue', () => {
|
|||
|
||||
sinon.assert.notCalled(fakeStore.stream as sinon.SinonStub);
|
||||
|
||||
noopQueue.streamJobs();
|
||||
drop(noopQueue.streamJobs());
|
||||
|
||||
sinon.assert.calledOnce(fakeStore.stream as sinon.SinonStub);
|
||||
|
||||
|
@ -804,7 +805,7 @@ describe('JobQueue', () => {
|
|||
maxAttempts: 99,
|
||||
});
|
||||
|
||||
noopQueue.streamJobs();
|
||||
drop(noopQueue.streamJobs());
|
||||
|
||||
await assert.isRejected(noopQueue.streamJobs());
|
||||
await assert.isRejected(noopQueue.streamJobs());
|
||||
|
|
|
@ -8,6 +8,7 @@ import EventEmitter, { once } from 'events';
|
|||
|
||||
import type { JobQueueStore, StoredJob } from '../../jobs/types';
|
||||
import { sleep } from '../../util/sleep';
|
||||
import { drop } from '../../util/drop';
|
||||
|
||||
export class TestJobQueueStore implements JobQueueStore {
|
||||
events = new EventEmitter();
|
||||
|
@ -20,7 +21,7 @@ export class TestJobQueueStore implements JobQueueStore {
|
|||
|
||||
constructor(jobs: ReadonlyArray<StoredJob> = []) {
|
||||
jobs.forEach(job => {
|
||||
this.insert(job);
|
||||
drop(this.insert(job));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ describe('handleMultipleSendErrors', () => {
|
|||
it('sleeps for the longest 413 Retry-After time', async () => {
|
||||
let done = false;
|
||||
|
||||
(async () => {
|
||||
void (async () => {
|
||||
try {
|
||||
await handleMultipleSendErrors({
|
||||
...defaultOptions,
|
||||
|
@ -134,7 +134,7 @@ describe('handleMultipleSendErrors', () => {
|
|||
it("doesn't sleep longer than the remaining time", async () => {
|
||||
let done = false;
|
||||
|
||||
(async () => {
|
||||
void (async () => {
|
||||
try {
|
||||
await handleMultipleSendErrors({
|
||||
...defaultOptions,
|
||||
|
|
|
@ -5,6 +5,7 @@ import { assert } from 'chai';
|
|||
import * as sinon from 'sinon';
|
||||
import { HTTPError } from '../../../textsecure/Errors';
|
||||
import * as durations from '../../../util/durations';
|
||||
import { drop } from '../../../util/drop';
|
||||
|
||||
import { sleepForRateLimitRetryAfterTime } from '../../../jobs/helpers/sleepForRateLimitRetryAfterTime';
|
||||
|
||||
|
@ -42,7 +43,7 @@ describe('sleepFor413RetryAfterTimeIfApplicable', () => {
|
|||
it('waits for 1 minute if the error lacks Retry-After info', async () => {
|
||||
let done = false;
|
||||
|
||||
(async () => {
|
||||
void (async () => {
|
||||
await sleepForRateLimitRetryAfterTime({
|
||||
err: {},
|
||||
log: createLogger(),
|
||||
|
@ -67,7 +68,7 @@ describe('sleepFor413RetryAfterTimeIfApplicable', () => {
|
|||
|
||||
let done = false;
|
||||
|
||||
(async () => {
|
||||
void (async () => {
|
||||
await sleepForRateLimitRetryAfterTime({
|
||||
err,
|
||||
log: createLogger(),
|
||||
|
@ -92,7 +93,7 @@ describe('sleepFor413RetryAfterTimeIfApplicable', () => {
|
|||
|
||||
let done = false;
|
||||
|
||||
(async () => {
|
||||
void (async () => {
|
||||
await sleepForRateLimitRetryAfterTime({
|
||||
err,
|
||||
log: createLogger(),
|
||||
|
@ -117,7 +118,7 @@ describe('sleepFor413RetryAfterTimeIfApplicable', () => {
|
|||
|
||||
let done = false;
|
||||
|
||||
(async () => {
|
||||
void (async () => {
|
||||
await sleepForRateLimitRetryAfterTime({
|
||||
err: { httpError },
|
||||
log: createLogger(),
|
||||
|
@ -142,7 +143,7 @@ describe('sleepFor413RetryAfterTimeIfApplicable', () => {
|
|||
|
||||
let done = false;
|
||||
|
||||
(async () => {
|
||||
void (async () => {
|
||||
await sleepForRateLimitRetryAfterTime({
|
||||
err: { httpError },
|
||||
log: createLogger(),
|
||||
|
@ -167,7 +168,7 @@ describe('sleepFor413RetryAfterTimeIfApplicable', () => {
|
|||
|
||||
let done = false;
|
||||
|
||||
(async () => {
|
||||
void (async () => {
|
||||
await sleepForRateLimitRetryAfterTime({
|
||||
err,
|
||||
log: createLogger(),
|
||||
|
@ -189,7 +190,7 @@ describe('sleepFor413RetryAfterTimeIfApplicable', () => {
|
|||
|
||||
let done = false;
|
||||
|
||||
(async () => {
|
||||
void (async () => {
|
||||
await sleepForRateLimitRetryAfterTime({
|
||||
err,
|
||||
log: createLogger(),
|
||||
|
@ -210,7 +211,7 @@ describe('sleepFor413RetryAfterTimeIfApplicable', () => {
|
|||
response: {},
|
||||
});
|
||||
|
||||
sleepForRateLimitRetryAfterTime({ err, log, timeRemaining: 9999999 });
|
||||
drop(sleepForRateLimitRetryAfterTime({ err, log, timeRemaining: 9999999 }));
|
||||
await clock.nextAsync();
|
||||
|
||||
sinon.assert.calledOnce(log.info);
|
||||
|
@ -225,7 +226,7 @@ describe('sleepFor413RetryAfterTimeIfApplicable', () => {
|
|||
response: {},
|
||||
});
|
||||
|
||||
sleepForRateLimitRetryAfterTime({ err, log, timeRemaining: 9999999 });
|
||||
drop(sleepForRateLimitRetryAfterTime({ err, log, timeRemaining: 9999999 }));
|
||||
await clock.nextAsync();
|
||||
|
||||
sinon.assert.calledOnce(log.info);
|
||||
|
|
|
@ -20,7 +20,7 @@ describe('sleep', () => {
|
|||
it('returns a promise that resolves after the specified number of milliseconds', async function test() {
|
||||
let isDone = false;
|
||||
|
||||
(async () => {
|
||||
void (async () => {
|
||||
await sleep(123);
|
||||
isDone = true;
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue