From 81c9af2b78ec27019acf717d5438c32caaac42b3 Mon Sep 17 00:00:00 2001 From: Ryan Noon Date: Tue, 21 Jun 2022 00:46:02 -0400 Subject: [PATCH] await bugs --- .eslintrc | 6 ++++-- src/api/_acks.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.eslintrc b/.eslintrc index 12266e2..6fea1e4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,7 +1,8 @@ { "parser": "@typescript-eslint/parser", "parserOptions": { - "ecmaVersion": 2021 + "ecmaVersion": 2021, + "project": "./tsconfig.json" }, "extends": [ "plugin:@typescript-eslint/recommended" @@ -10,6 +11,7 @@ "indent": ["error", "tab", { "SwitchCase": 1 }], "semi": [2, "always"], "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-empty-interface": "off" + "@typescript-eslint/no-empty-interface": "off", + "@typescript-eslint/no-floating-promises": "error" } } diff --git a/src/api/_acks.ts b/src/api/_acks.ts index 135d20d..6bbf327 100644 --- a/src/api/_acks.ts +++ b/src/api/_acks.ts @@ -44,7 +44,7 @@ export async function checkForReminders() { const incomplete: { channel: string, ts: string }[] = []; // check each of them - map(vals, async (val, idx) => { + await map(vals, async (val, idx) => { const [channel, ts] = val.split(':'); console.log('checkForReminders val: ', { channel, ts, val, idx }); try { @@ -55,7 +55,7 @@ export async function checkForReminders() { incomplete.push({ channel, ts }); } } catch (e) { - console.error('checkForReminders error: ', { error: e, val }); + console.error('checkForReminders error: ', { error: e, val, idx }); } }, DEFAULT_CONCURRENCY); @@ -74,7 +74,7 @@ async function saveReminders(reminders: { channel: string, ts: string }[]): Prom const score = new Date().getTime(); const adds = reminders.map(r => ({ score, member: `${r.channel}:${r.ts}` })); const first = adds.shift(); - redis.zadd(REDIS_ACK_KEY, first, ...adds); // dirty hack because these typings are disgusting + await redis.zadd(REDIS_ACK_KEY, first, ...adds); // dirty hack because these typings are disgusting } export async function checkMessageAcks(channel: string, ts: string, saveReminder = true): Promise<{ isComplete: boolean }> { @@ -102,10 +102,10 @@ export async function checkMessageAcks(channel: string, ts: string, saveReminder usersDidReact.add(u); } } - + 4; const usersShouldReact = new Set(mentions.userIds); - map(mentions.userGroupIds, async groupId => { + await map(mentions.userGroupIds, async groupId => { const groupResp = await slack.usergroups.users.list({ usergroup: groupId }); @@ -138,7 +138,7 @@ export async function checkMessageAcks(channel: string, ts: string, saveReminder await log({ channel, threadTs: ts }, 'ready to send reminders', { message, mentions, reactions, usersDidReact: [...usersDidReact], usersShouldReact: [...usersShouldReact], usersToPing }); - map(usersToPing, async userToPing => { + await map(usersToPing, async userToPing => { await slack.chat.postMessage({ channel: userToPing, text: `Hey <@${userToPing}>! Heads up that <@${message.user}> requested you acknowledge their message by reacting to it: ${permalink}`