Add no-misused/floating-promises lint rule

This commit is contained in:
Fedor Indutny 2022-12-21 10:41:48 -08:00 committed by GitHub
parent 1a68c3db62
commit ed271d92ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
150 changed files with 1296 additions and 991 deletions

View file

@ -721,7 +721,7 @@ export default class AccountManager extends EventTarget {
// Intentionally not awaiting becase `updatePNIIdentity` runs on an
// Encrypted queue of MessageReceiver and we don't want to await remote
// endpoints and block message processing.
this.queueTask(async () => {
void this.queueTask(async () => {
try {
const keys = await this.generateKeys(
SIGNED_KEY_GEN_BATCH_SIZE,
@ -847,8 +847,8 @@ export default class AccountManager extends EventTarget {
await Promise.all(promises);
// This is primarily for the signed prekey summary it logs out
this.cleanSignedPreKeys(UUIDKind.ACI);
this.cleanSignedPreKeys(UUIDKind.PNI);
void this.cleanSignedPreKeys(UUIDKind.ACI);
void this.cleanSignedPreKeys(UUIDKind.PNI);
return {
...result,
@ -885,7 +885,7 @@ export default class AccountManager extends EventTarget {
// Intentionally not awaiting since this is processed on encrypted queue
// of MessageReceiver.
this.queueTask(async () => {
void this.queueTask(async () => {
try {
const keys = await this.generateKeys(
SIGNED_KEY_GEN_BATCH_SIZE,

View file

@ -13,7 +13,7 @@ export function init(signalProtocolStore: SignalProtocolStore): void {
uuid.toString(),
'private'
);
conversation.addKeyChange(reason);
void conversation.addKeyChange(reason);
}
);
}

View file

@ -40,6 +40,7 @@ import { verifySignature } from '../Curve';
import { strictAssert } from '../util/assert';
import type { BatcherType } from '../util/batcher';
import { createBatcher } from '../util/batcher';
import { drop } from '../util/drop';
import { dropNull } from '../util/dropNull';
import { normalizeUuid } from '../util/normalizeUuid';
import { parseIntOrThrow } from '../util/parseIntOrThrow';
@ -312,7 +313,7 @@ export default class MessageReceiver
processBatch: (items: Array<CacheAddItemType>) => {
// Not returning the promise here because we don't want to stall
// the batch.
this.decryptAndCacheBatch(items);
void this.decryptAndCacheBatch(items);
},
});
this.cacheRemoveBatcher = createBatcher<string>({
@ -337,13 +338,15 @@ export default class MessageReceiver
request.respond(200, 'OK');
if (request.verb === 'PUT' && request.path === '/api/v1/queue/empty') {
this.incomingQueue.add(
createTaskWithTimeout(
async () => {
this.onEmpty();
},
'incomingQueue/onEmpty',
TASK_WITH_TIMEOUT_OPTIONS
drop(
this.incomingQueue.add(
createTaskWithTimeout(
async () => {
this.onEmpty();
},
'incomingQueue/onEmpty',
TASK_WITH_TIMEOUT_OPTIONS
)
)
);
}
@ -422,22 +425,26 @@ export default class MessageReceiver
}
};
this.incomingQueue.add(
createTaskWithTimeout(
job,
'incomingQueue/websocket',
TASK_WITH_TIMEOUT_OPTIONS
drop(
this.incomingQueue.add(
createTaskWithTimeout(
job,
'incomingQueue/websocket',
TASK_WITH_TIMEOUT_OPTIONS
)
)
);
}
public reset(): void {
// We always process our cache before processing a new websocket message
this.incomingQueue.add(
createTaskWithTimeout(
async () => this.queueAllCached(),
'incomingQueue/queueAllCached',
TASK_WITH_TIMEOUT_OPTIONS
drop(
this.incomingQueue.add(
createTaskWithTimeout(
async () => this.queueAllCached(),
'incomingQueue/queueAllCached',
TASK_WITH_TIMEOUT_OPTIONS
)
)
);
@ -626,11 +633,13 @@ export default class MessageReceiver
//
private async dispatchAndWait(id: string, event: Event): Promise<void> {
this.appQueue.add(
createTaskWithTimeout(
async () => Promise.all(this.dispatchEvent(event)),
`dispatchEvent(${event.type}, ${id})`,
TASK_WITH_TIMEOUT_OPTIONS
drop(
this.appQueue.add(
createTaskWithTimeout(
async () => Promise.all(this.dispatchEvent(event)),
`dispatchEvent(${event.type}, ${id})`,
TASK_WITH_TIMEOUT_OPTIONS
)
)
);
}
@ -707,16 +716,24 @@ export default class MessageReceiver
);
// We don't await here because we don't want this to gate future message processing
this.appQueue.add(
createTaskWithTimeout(emitEmpty, 'emitEmpty', TASK_WITH_TIMEOUT_OPTIONS)
drop(
this.appQueue.add(
createTaskWithTimeout(
emitEmpty,
'emitEmpty',
TASK_WITH_TIMEOUT_OPTIONS
)
)
);
};
const waitForEncryptedQueue = async () => {
this.addToQueue(
waitForDecryptedQueue,
'onEmpty/waitForDecrypted',
TaskType.Decrypted
drop(
this.addToQueue(
waitForDecryptedQueue,
'onEmpty/waitForDecrypted',
TaskType.Decrypted
)
);
};
@ -725,25 +742,29 @@ export default class MessageReceiver
// Resetting count so everything from the websocket after this starts at zero
this.count = 0;
this.addToQueue(
waitForEncryptedQueue,
'onEmpty/waitForEncrypted',
TaskType.Encrypted
drop(
this.addToQueue(
waitForEncryptedQueue,
'onEmpty/waitForEncrypted',
TaskType.Encrypted
)
);
};
const waitForCacheAddBatcher = async () => {
await this.decryptAndCacheBatcher.onIdle();
this.incomingQueue.add(
createTaskWithTimeout(
waitForIncomingQueue,
'onEmpty/waitForIncoming',
TASK_WITH_TIMEOUT_OPTIONS
drop(
this.incomingQueue.add(
createTaskWithTimeout(
waitForIncomingQueue,
'onEmpty/waitForIncoming',
TASK_WITH_TIMEOUT_OPTIONS
)
)
);
};
waitForCacheAddBatcher();
drop(waitForCacheAddBatcher());
}
private updateProgress(count: number): void {
@ -835,15 +856,20 @@ export default class MessageReceiver
};
// Maintain invariant: encrypted queue => decrypted queue
this.addToQueue(
async () => {
this.queueDecryptedEnvelope(decryptedEnvelope, payloadPlaintext);
},
`queueDecryptedEnvelope(${getEnvelopeId(decryptedEnvelope)})`,
TaskType.Encrypted
drop(
this.addToQueue(
async () => {
void this.queueDecryptedEnvelope(
decryptedEnvelope,
payloadPlaintext
);
},
`queueDecryptedEnvelope(${getEnvelopeId(decryptedEnvelope)})`,
TaskType.Encrypted
)
);
} else {
this.queueCachedEnvelope(item, envelope);
void this.queueCachedEnvelope(item, envelope);
}
} catch (error) {
log.error(
@ -876,11 +902,13 @@ export default class MessageReceiver
if (this.isEmptied) {
this.clearRetryTimeout();
this.retryCachedTimeout = setTimeout(() => {
this.incomingQueue.add(
createTaskWithTimeout(
async () => this.queueAllCached(),
'queueAllCached',
TASK_WITH_TIMEOUT_OPTIONS
drop(
this.incomingQueue.add(
createTaskWithTimeout(
async () => this.queueAllCached(),
'queueAllCached',
TASK_WITH_TIMEOUT_OPTIONS
)
)
);
}, RETRY_TIMEOUT);
@ -1155,11 +1183,13 @@ export default class MessageReceiver
logId = getEnvelopeId(unsealedEnvelope);
const taskId = `dispatchEvent(EnvelopeEvent(${logId}))`;
this.addToQueue(
async () =>
this.dispatchAndWait(taskId, new EnvelopeEvent(unsealedEnvelope)),
taskId,
TaskType.Decrypted
drop(
this.addToQueue(
async () =>
this.dispatchAndWait(taskId, new EnvelopeEvent(unsealedEnvelope)),
taskId,
TaskType.Decrypted
)
);
return this.decryptEnvelope(stores, unsealedEnvelope, uuidKind);
@ -1887,10 +1917,12 @@ export default class MessageReceiver
);
// Avoid deadlocks by scheduling processing on decrypted queue
this.addToQueue(
async () => this.dispatchEvent(event),
`decrypted/dispatchEvent/DecryptionErrorEvent(${envelopeId})`,
TaskType.Decrypted
drop(
this.addToQueue(
async () => this.dispatchEvent(event),
`decrypted/dispatchEvent/DecryptionErrorEvent(${envelopeId})`,
TaskType.Decrypted
)
);
} else {
this.removeFromCache(envelope);
@ -2099,7 +2131,7 @@ export default class MessageReceiver
},
this.removeFromCache.bind(this, envelope)
);
this.dispatchAndWait(logId, ev);
void this.dispatchAndWait(logId, ev);
return;
}
@ -2158,7 +2190,7 @@ export default class MessageReceiver
},
this.removeFromCache.bind(this, envelope)
);
this.dispatchAndWait(logId, ev);
void this.dispatchAndWait(logId, ev);
});
return;
}
@ -2828,7 +2860,7 @@ export default class MessageReceiver
}
if (sentMessage.storyMessage) {
this.handleStoryMessage(
void this.handleStoryMessage(
envelope,
sentMessage.storyMessage,
sentMessage
@ -2867,7 +2899,7 @@ export default class MessageReceiver
return this.handleContacts(envelope, syncMessage.contacts);
}
if (syncMessage.groups) {
this.handleGroups(envelope, syncMessage.groups);
void this.handleGroups(envelope, syncMessage.groups);
return;
}
if (syncMessage.blocked) {
@ -3333,7 +3365,7 @@ export default class MessageReceiver
if (changed) {
log.info('handleBlocked: Block list changed, forcing re-render.');
const uniqueIdentifiers = Array.from(new Set(allIdentifiers));
window.ConversationController.forceRerender(uniqueIdentifiers);
void window.ConversationController.forceRerender(uniqueIdentifiers);
}
}

View file

@ -520,7 +520,7 @@ export default class OutgoingMessage {
this.numberCompleted();
if (this.sendLogCallback) {
this.sendLogCallback({
void this.sendLogCallback({
identifier,
deviceIds,
});
@ -559,7 +559,7 @@ export default class OutgoingMessage {
this.numberCompleted();
if (this.sendLogCallback) {
this.sendLogCallback({
void this.sendLogCallback({
identifier,
deviceIds,
});

View file

@ -19,7 +19,7 @@ export class RotateSignedPreKeyListener {
protected scheduleRotationForNow(): void {
const now = Date.now();
window.textsecure.storage.put('nextSignedKeyRotationTime', now);
void window.textsecure.storage.put('nextSignedKeyRotationTime', now);
}
protected setTimeoutForNextRun(): void {
@ -46,7 +46,7 @@ export class RotateSignedPreKeyListener {
private scheduleNextRotation(): void {
const now = Date.now();
const nextTime = now + ROTATION_INTERVAL;
window.textsecure.storage.put('nextSignedKeyRotationTime', nextTime);
void window.textsecure.storage.put('nextSignedKeyRotationTime', nextTime);
}
private async run(): Promise<void> {
@ -67,7 +67,7 @@ export class RotateSignedPreKeyListener {
private runWhenOnline() {
if (window.navigator.onLine) {
this.run();
void this.run();
} else {
log.info('We are offline; keys will be rotated when we are next online');
const listener = () => {

View file

@ -1246,7 +1246,7 @@ export default class MessageSender {
});
recipients.forEach(identifier => {
this.queueJobForIdentifier(identifier, async () =>
void this.queueJobForIdentifier(identifier, async () =>
outgoing.sendToIdentifier(identifier)
);
});
@ -2186,7 +2186,7 @@ export default class MessageSender {
return;
}
if (!initialSavePromise) {
if (initialSavePromise === undefined) {
initialSavePromise = window.Signal.Data.insertSentProto(
{
contentHint,

View file

@ -219,7 +219,7 @@ export class SocketManager extends EventListener {
}
}
reconnect();
void reconnect();
return;
}
@ -244,7 +244,7 @@ export class SocketManager extends EventListener {
return;
}
reconnect();
void reconnect();
});
}

View file

@ -139,6 +139,6 @@ export default class SyncRequest {
}
start(): void {
this.inner.start();
void this.inner.start();
}
}

View file

@ -1130,7 +1130,7 @@ export function initialize({
});
if (useWebSocket) {
socketManager.authenticate({ username, password });
void socketManager.authenticate({ username, password });
}
const { directoryUrl, directoryMRENCLAVE } = directoryConfig;
@ -1368,7 +1368,7 @@ export function initialize({
function checkSockets(): void {
// Intentionally not awaiting
socketManager.check();
void socketManager.check();
}
async function onOnline(): Promise<void> {
@ -1392,7 +1392,7 @@ export function initialize({
}
function onHasStoriesDisabledChange(newValue: boolean): void {
socketManager.onHasStoriesDisabledChange(newValue);
void socketManager.onHasStoriesDisabledChange(newValue);
}
async function getConfig() {

View file

@ -227,7 +227,7 @@ export default class WebSocketResource extends EventTarget {
if (!this.keepalive) {
return;
}
this.keepalive.send();
void this.keepalive.send();
}
public close(code = 3000, reason?: string): void {

View file

@ -81,7 +81,7 @@ export abstract class CDSSocketManagerBase<
throw error;
} finally {
log.info('CDSSocketManager: closing socket');
socket.close(3000, 'Normal');
void socket.close(3000, 'Normal');
}
}