Skip to content

Commit

Permalink
Mark expected floating promises with the void operator
Browse files Browse the repository at this point in the history
Update @balena/lint from 7.0.2 to 7.1.1

Change-type: patch
See: balena-io/pinejs#682 (comment)
  • Loading branch information
thgreasi committed Aug 30, 2023
1 parent e3d6b54 commit 763f512
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 41 deletions.
7 changes: 3 additions & 4 deletions init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ async function onInitHooks() {
});

// Pre-fetch the device types and populate the cache w/o blocking the API startup
// eslint-disable-next-line @typescript-eslint/no-floating-promises
getAccessibleDeviceTypes(sbvrUtils.api.resin);
void getAccessibleDeviceTypes(sbvrUtils.api.resin);

await sbvrUtils.db.transaction((tx) =>
createAll(tx, permissionNames, auth.ROLES, auth.KEYS, {}),
Expand Down Expand Up @@ -257,5 +256,5 @@ const init = async () => {
process.exit(1);
}
};
// eslint-disable-next-line @typescript-eslint/no-floating-promises
init();

void init();
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"validator": "^13.9.0"
},
"devDependencies": {
"@balena/lint": "^7.0.2",
"@balena/lint": "^7.1.1",
"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1",
"@types/mockery": "^1.4.30",
Expand Down
12 changes: 4 additions & 8 deletions src/features/device-heartbeat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ export class DeviceOnlineStateManager extends EventEmitter<{
});

// create the RedisMQ queue and start consuming messages...
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.rsmq
void this.rsmq
.createQueueAsync({ qname: DeviceOnlineStateManager.EXPIRED_QUEUE })
.catch((err) => {
if (err.name !== 'queueExists') {
Expand All @@ -211,8 +210,7 @@ export class DeviceOnlineStateManager extends EventEmitter<{
}

private setupQueueStatsEmitter(interval: number) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
setTimeout(interval, undefined, { ref: false }).then(async () => {
void setTimeout(interval, undefined, { ref: false }).then(async () => {
try {
const startAt = Date.now();
const queueAttributes = await this.rsmq.getQueueAttributesAsync({
Expand Down Expand Up @@ -282,8 +280,7 @@ export class DeviceOnlineStateManager extends EventEmitter<{

private consume() {
// pull a message from the queue...
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.rsmq
void this.rsmq
.receiveMessageAsync({
qname: DeviceOnlineStateManager.EXPIRED_QUEUE,
vt: DeviceOnlineStateManager.RSMQ_READ_TIMEOUT, // prevent other consumers seeing the same message (if any) preventing multiple API agents from processing it...
Expand All @@ -308,8 +305,7 @@ export class DeviceOnlineStateManager extends EventEmitter<{
deviceId,
DeviceOnlineStates.Timeout,
);
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.scheduleChangeOfStateForDevice(
void this.scheduleChangeOfStateForDevice(
deviceId,
await this.getDeviceOnlineState(deviceId),
DeviceOnlineStates.Timeout,
Expand Down
15 changes: 5 additions & 10 deletions src/features/device-logs/lib/backends/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,12 @@ export class RedisBackend implements DeviceLogsBackend {
const key = this.getKey(ctx);
if (!this.subscriptions.listenerCount(key)) {
const subscribersKey = this.getKey(ctx, 'subscribers');
// eslint-disable-next-line @typescript-eslint/no-floating-promises
pubSub[SUBSCRIBECMD](key);
void pubSub[SUBSCRIBECMD](key);
// Increment the subscribers counter to recognize we've subscribed
// eslint-disable-next-line @typescript-eslint/no-floating-promises
redis.incrSubscribers(subscribersKey);
void redis.incrSubscribers(subscribersKey);
// Start a heartbeat to ensure the subscribers counter stays alive whilst we're subscribed
this.subscriptionHeartbeats[key] = setInterval(() => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
redis.expire(subscribersKey, LOGS_SUBSCRIPTION_EXPIRY_SECONDS);
void redis.expire(subscribersKey, LOGS_SUBSCRIPTION_EXPIRY_SECONDS);
}, LOGS_SUBSCRIPTION_EXPIRY_HEARTBEAT_SECONDS);
}
this.subscriptions.on(key, subscription);
Expand All @@ -205,17 +202,15 @@ export class RedisBackend implements DeviceLogsBackend {
// Clear the heartbeat
clearInterval(this.subscriptionHeartbeats[key]);
// And decrement the subscribers counter
// eslint-disable-next-line @typescript-eslint/no-floating-promises
redis.decrSubscribers(subscribersKey).then((n) => {
void redis.decrSubscribers(subscribersKey).then((n) => {
if (n < 0) {
captureException(
new Error(),
`Decremented logs subscribers below 0, n: '${n}', uuid: '${ctx.uuid}'`,
);
}
});
// eslint-disable-next-line @typescript-eslint/no-floating-promises
pubSub[UNSUBSCRIBECMD](key);
void pubSub[UNSUBSCRIBECMD](key);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/features/device-provisioning/hooks/cache-invalidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ const setupCacheInvalidation = <K extends string>(
tx.on('end', () => {
for (const affectedItem of affectedItems) {
// Run in the background as this is not a reason to fail the request
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
void (async () => {
try {
await cache.delete(affectedItem[keyProperty]);
} catch (err) {
Expand Down
6 changes: 2 additions & 4 deletions src/features/device-provisioning/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ export const register: RequestHandler = async (req, res) => {
// TODO: Replace this manual rollback on request closure with a more generic/automated version
onFinished(res, () => {
if (!tx.isClosed()) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
tx.rollback();
void tx.rollback();
}
});

Expand Down Expand Up @@ -106,8 +105,7 @@ export const register: RequestHandler = async (req, res) => {

// Clear the device existence cache for the just registered device
// in case it tried to communicate with the API before registering
// eslint-disable-next-line @typescript-eslint/no-floating-promises
checkDeviceExistsIsFrozen.delete(response.uuid);
void checkDeviceExistsIsFrozen.delete(response.uuid);

res.status(201).json(response);
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ hooks.addPureHook('POST', 'resin', 'application', {
POSTRUN: async ({ request }) => {
if (request.values.is_host) {
// no need to wait for the cache invalidation
// eslint-disable-next-line @typescript-eslint/no-floating-promises
getDeviceTypes.delete();
void getDeviceTypes.delete();
}
},
});
Expand All @@ -16,8 +15,7 @@ hooks.addPureHook('PATCH', 'resin', 'application', {
const affectedIds = request.affectedIds!;
if (request.values.is_host && affectedIds.length !== 0) {
// no need to wait for the cache invalidation
// eslint-disable-next-line @typescript-eslint/no-floating-promises
getDeviceTypes.delete();
void getDeviceTypes.delete();
}
},
});
6 changes: 2 additions & 4 deletions test/13_loki-backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ describe('loki backend', () => {
const loki = new LokiBackend();
const log = createLog();
const incomingLog = await new Bluebird(async (resolve) => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
loki.subscribe(ctx, resolve);
void loki.subscribe(ctx, resolve);
await setTimeout(100); // wait for the subscription to connect
await loki.publish(ctx, [_.clone(log)]);
}).timeout(5000, 'Subscription did not receive log');
Expand All @@ -112,8 +111,7 @@ describe('loki backend', () => {
const loki = new LokiBackend();
await new Bluebird(async (resolve) => {
let countLogs = 0;
// eslint-disable-next-line @typescript-eslint/no-floating-promises
loki.subscribe(ctx, () => {
void loki.subscribe(ctx, () => {
countLogs += 1;
if (countLogs === 5) {
resolve();
Expand Down

0 comments on commit 763f512

Please sign in to comment.