Skip to content

Commit

Permalink
fix: remove promise race
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmo314 committed May 8, 2022
1 parent c79180b commit 7de5d48
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions agent/src/agents/twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,12 @@ async function getChatAgent(
}
});

await twitch.chat.connect();

return twitch.chat;
}

const agents: { [userId: string]: Chat } = {};
const agents: { [userId: string]: Promise<Chat> } = {};

async function join(
firebase: FirebaseAdapter,
Expand All @@ -255,10 +257,9 @@ async function join(
// }

if (!agents[userId]) {
agents[userId] = await getChatAgent(firebase, agentId, username, userId);
await agents[userId].connect();
agents[userId] = getChatAgent(firebase, agentId, username, userId);
}
const chat = agents[userId];
const chat = await agents[userId];
log.info({ channel, agentId, provider }, "assigned to channel");
await Promise.race([
chat.join(channel),
Expand Down

0 comments on commit 7de5d48

Please sign in to comment.