racket-cord icon indicating copy to clipboard operation
racket-cord copied to clipboard

Occasional contract violation in update-status

Open ja-cop opened this issue 1 year ago • 0 comments

Example error (preceded by two lines of debug output):

discord: Error: Received EOF on websocket
[error] discord: Error: Received EOF on websocket
ws-send!: contract violation:
  expected: ws-conn?
  given: #f
  argument position: 1st
  payload argument...: "{\"d\":{\"activities\":[{\"name\":\"yabma (3 / 32)\",\"type\":0}],\"afk\":false,\"since\":null,\"status\":\"online\"},\"op\":3}"
  #:final-fragment? (optional) argument...: 'default-arg16524
  #:payload-type (optional) argument...: 'default-arg16524
  #:flush? (optional) argument...: 'default-arg16524
  errortrace...:
   /usr/src/sc-chat-bridge/rcon-status.rkt:56:2: (update-status (bot-client) #:status discord-status #:activities (list activity))
   /usr/src/sc-chat-bridge/rcon-status.rkt:73:6: (cond ((eq? evt alarm) (update-bot-activity status) status) (else evt))
   /usr/src/sc-chat-bridge/rcon-status.rkt:80:4: (loop next-status)
  context...:
   /usr/src/pkgs/racket-cord/main.rkt:118:0: update-status
   /usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt:555:3
   /usr/src/sc-chat-bridge/rcon-status.rkt:65:2: loop

What I'm guessing is happening, is that occasionally the web socket connection needs to be reestablished, and if update-status is called after it's closed but before it's reestablished, this will happen. My bot sends status updates every two minutes because of https://github.com/discord/discord-api-docs/issues/834, so this has happened a few times over the last week or so.

I'm not that familiar with the racket-cord codebase yet and I don't know what the best solution is, but I'll leave this issue here for now.

ja-cop avatar Jan 14 '25 04:01 ja-cop