New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError on unordered CHANNEL_CREATE #21

Closed
Hornwitser opened this Issue Oct 19, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@Hornwitser
Copy link
Contributor

Hornwitser commented Oct 19, 2015

It's possible that messages are reordered such that a MESSAGE_CREATE event comes before the corresponding CHANNEL_CREATE for the private chat. This causes the code to crash with an AssertionError.

File "bot.py", line 316, in <module>
    charset='utf8mb4',
  File "/home/julian/prog/record/logger/discord/client.py", line 518, in run
    self.ws.run()
  File "/usr/lib/python3.5/site-packages/ws4py/websocket.py", line 427, in run
    if not self.once():
  File "/usr/lib/python3.5/site-packages/ws4py/websocket.py", line 305, in once
    if not self.process(b):
  File "/usr/lib/python3.5/site-packages/ws4py/websocket.py", line 377, in process
    self.received_message(s.message)
  File "/home/julian/prog/record/logger/discord/client.py", line 128, in received_message
    self.dispatch('socket_update', event, data)
  File "/home/julian/prog/record/logger/discord/client.py", line 505, in dispatch
    getattr(self, handle_method, _null_event)(*args, **kwargs)
  File "/home/julian/prog/record/logger/discord/client.py", line 513, in handle_socket_update
    getattr(self.connection, method)(data)
  File "/home/julian/prog/record/logger/discord/client.py", line 211, in handle_message_create
    message = Message(channel=channel, **data)
  File "/home/julian/prog/record/logger/discord/message.py", line 89, in __init__
    self._upgrade_to_member()
  File "/home/julian/prog/record/logger/discord/message.py", line 92, in _upgrade_to_member
    assert self.channel is not None
AssertionError

WebSocket Context (not much to see, it's just a message with an unknown channel id)

@Rapptz Rapptz added the bug label Oct 19, 2015

@Rapptz Rapptz modified the milestone: v0.9.0 Oct 20, 2015

@Rapptz

This comment has been minimized.

Copy link
Owner

Rapptz commented Oct 28, 2015

As of c49ff36 the Message.channel could be discord.Object in very rare scenarios.

@Rapptz Rapptz closed this Oct 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment