discord-relay-chat / drc

Discord Relay Chat
https://discordrc.com
MIT License
18 stars 3 forks source link

Race between IRC and Discord daemons on irc:responseJoinChannel #5

Open edfletcher opened 1 year ago

edfletcher commented 1 year ago

shoky kindly noted in the IRC channel that it's working fine for them, but when trying to join them in #drc (because #discordrc throws errors saying "discord not allowed in name": need to file a bug for that too!) the UI makes it seem like joining worked fine but no messages came through. After enabling debug logging and trying again I managed to catch this:

drc-discord-1  | 2022-12-22T00:12:14.857Z [debug] REG'ed OTH for irc:responseJoinChannel discrim drc
drc-irc-1      | 2022-12-22T00:12:14.865Z [error] bad Redis msg TypeError: Cannot read properties of undefined (reading 'name')
drc-irc-1      |     at getChannelJoinFunc (/usr/src/drc/irc/ipcMessage.js:31:54)
drc-irc-1      |     at module.exports (/usr/src/drc/irc/ipcMessage.js:208:24)
drc-irc-1      |     at runMicrotasks (<anonymous>)
drc-irc-1      |     at processTicksAndRejections (node:internal/process/task_queues:96:5) {"type":"discord:requestJoinChannel:irc","data":{"name":"drc","id":"1055276387918946404","parentId":"911345720680939530"}}
drc-irc-1      | 2022-12-22T00:12:14.865Z [debug] Redis msg! drc-dev {"type":"irc:responseJoinChannel","data":{"name":"drc","id":"1055276387918946404","parentId":"911345720680939530"}}
edfletcher commented 1 year ago

FA'ed this and indeed that failure mode matches the race condition described by this comment. Really need to fix that, so not closing this but retitling to more-correctly describe the failure mode.

Fixing should just be a matter of adding an intermediate state (or sync RPC?) that waits on the irc:topic before completing the channel-join (and therefore triggering the irc:responseJoinChannel code path)