Skip to content

Commit

Permalink
Remove floating promises (safe-global#1095)
Browse files Browse the repository at this point in the history
This enables a linting warning for floating promises and solves the few warnings that were found after enabling it.

---

* Catch and log cache clearing failures after deletion

* Remove floating promises
  • Loading branch information
iamacook authored Feb 1, 2024
1 parent 0acd187 commit 585e154
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ module.exports = {
{ assertionStyle: 'as' },
],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-floating-promises': 'warn',
},
};
2 changes: 1 addition & 1 deletion src/datasources/cache/cache.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function redisClientFactory(
client.on('error', (err) =>
loggingService.error(`Redis client error: ${err}`),
);
client.connect();
await client.connect();
return client;
}

Expand Down
4 changes: 2 additions & 2 deletions src/datasources/cache/redis.cache.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('RedisCacheService', () => {
faker.string.sample(),
);
const value = fakeJson();
redisClient.hSet(cacheDir.key, cacheDir.field, value);
await redisClient.hSet(cacheDir.key, cacheDir.field, value);

const storedValue = await redisCacheService.get(cacheDir);

Expand All @@ -117,7 +117,7 @@ describe('RedisCacheService', () => {
faker.string.sample(),
);
const value = fakeJson();
redisClient.hSet(cacheDir.key, cacheDir.field, value);
await redisClient.hSet(cacheDir.key, cacheDir.field, value);

await redisCacheService.deleteByKey(cacheDir.key);

Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ async function bootstrap(): Promise<void> {
await app.listen(applicationPort);
}

bootstrap();
void bootstrap();
2 changes: 1 addition & 1 deletion src/routes/alerts/alerts.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export class AlertsController {
@Body(AlertValidationPipe)
alertPayload: Alert,
): Promise<void> {
this.alertsService.onAlert(alertPayload);
await this.alertsService.onAlert(alertPayload);
}
}

0 comments on commit 585e154

Please sign in to comment.