Krognol/discordnim

Possible websocket issue when bot is in a large guild

Krognol opened this issue · 2 comments

Possible websocket issue when bot is in a large guild

When connecting to the gateway the websocket may fail to read (for reasons unknown) and most likely you will get some error that looks like this:

value out of range: -19277
  recv's lead up to read of failed Future:
    Traceback (most recent call last)
    basic_bot.nim(24)        basic_bot
    asyncdispatch.nim(1000)  waitFor
    asyncdispatch.nim(1035)  poll
    asyncdispatch.nim(180)   processPendingCallbacks
    asyncmacro.nim(34)       cb
    asyncmacro.nim(334)      recvLineIter
    asyncfutures.nim(109)    complete
    asyncmacro.nim(34)       cb
    asyncmacro.nim(334)      newAsyncWebsocketIter
    asyncfutures.nim(109)    complete
    asyncmacro.nim(34)       cb
    asyncdispatch.nim(1000)  startSessionIter
    asyncdispatch.nim(1035)  poll
    asyncdispatch.nim(180)   processPendingCallbacks
    asyncmacro.nim(34)       cb
    shared.nim(138)          recvFrameIter
    asyncmacro.nim(387)      recv
    asyncmacro.nim(34)       cb
    asyncnet.nim(367)        recvIter
    system.nim(2662)         sysFatal
  recvFrame's lead up to read of failed Future:
    Traceback (most recent call last)
    basic_bot.nim(24)        basic_bot
    asyncdispatch.nim(1000)  waitFor
    asyncdispatch.nim(1035)  poll
    asyncdispatch.nim(180)   processPendingCallbacks
    asyncmacro.nim(34)       cb
    asyncmacro.nim(334)      recvLineIter
    asyncfutures.nim(109)    complete
    asyncmacro.nim(34)       cb
    asyncmacro.nim(334)      newAsyncWebsocketIter
    asyncfutures.nim(109)    complete
    asyncmacro.nim(34)       cb
    asyncdispatch.nim(1000)  startSessionIter
    asyncdispatch.nim(1035)  poll
    asyncdispatch.nim(180)   processPendingCallbacks
    asyncmacro.nim(34)       cb
    shared.nim(138)          recvFrameIter
    asyncmacro.nim(387)      recv
    asyncmacro.nim(34)       cb
    asyncnet.nim(367)        recvIter
    system.nim(2662)         sysFatal
    [[reraised from:
    basic_bot.nim(24)        basic_bot
    asyncdispatch.nim(1000)  waitFor
    asyncdispatch.nim(1035)  poll
    asyncdispatch.nim(180)   processPendingCallbacks
    asyncmacro.nim(34)       cb
    asyncmacro.nim(334)      recvLineIter
    asyncfutures.nim(109)    complete
    asyncmacro.nim(34)       cb
    asyncmacro.nim(334)      newAsyncWebsocketIter
    asyncfutures.nim(109)    complete
    asyncmacro.nim(34)       cb
    asyncdispatch.nim(1000)  startSessionIter
    asyncdispatch.nim(1035)  poll
    asyncdispatch.nim(180)   processPendingCallbacks
    asyncmacro.nim(34)       cb
    asyncmacro.nim           recvFrameIter
    asyncfutures.nim(220)    read
    ]]

Currently investigating the cause.

The payload recieved appears to be normal however.

data:{"t":"READY","s":1,"op":0,"d":{"v":7,"user_settings":{},"user":{"verified":true,"username":"Test Bot","mfa_enabled":true,"id":"2647435426504376","email":null,"discriminator":"0221","bot":true,"avatar":"6038c8a365d7ceb97f0c2c19755013c2"},"session_id":"f13c684b78ce5ae2a3222f12c","relationships":[],"private_channels":[],"presences":[],"guilds":[{"unavailable":true,"id":"243087636560871424"}],"_trace":["discord-gateway-prd-1-27","discord-sessions-prd-1-8"]}}