Skip to content
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

NoMethodError when removed_member_ids is nil #186

Open
holdank opened this issue Oct 16, 2022 · 2 comments · May be fixed by #187
Open

NoMethodError when removed_member_ids is nil #186

holdank opened this issue Oct 16, 2022 · 2 comments · May be fixed by #187

Comments

@holdank
Copy link

holdank commented Oct 16, 2022

Summary

seeing this error result in closed connections

[ERROR` : websocket @ 2022-10-16 15:22:46.660] Exception: #<NoMethodError: undefined method `each' for nil:NilClass

        data['removed_member_ids'].each do |member_id|
                                  ^^^^^>
[ERROR : websocket @ 2022-10-16 15:22:46.661] /usr/local/rvm/gems/ruby-3.1.2/bundler/gems/discordrb-1cd5603d23e0/lib/discordrb/bot.rb:1603:in `handle_dispatch'
[ERROR : websocket @ 2022-10-16 15:22:46.661] /usr/local/rvm/gems/ruby-3.1.2/bundler/gems/discordrb-1cd5603d23e0/lib/discordrb/bot.rb:769:in `dispatch'
[ERROR : websocket @ 2022-10-16 15:22:46.661] /usr/local/rvm/gems/ruby-3.1.2/bundler/gems/discordrb-1cd5603d23e0/lib/discordrb/gateway.rb:730:in `handle_dispatch'
[ERROR : websocket @ 2022-10-16 15:22:46.661] /usr/local/rvm/gems/ruby-3.1.2/bundler/gems/discordrb-1cd5603d23e0/lib/discordrb/gateway.rb:694:in `handle_message'
[ERROR : websocket @ 2022-10-16 15:22:46.661] /usr/local/rvm/gems/ruby-3.1.2/bundler/gems/discordrb-1cd5603d23e0/lib/discordrb/gateway.rb:631:in `websocket_loop'
[ERROR : websocket @ 2022-10-16 15:22:46.661] /usr/local/rvm/gems/ruby-3.1.2/bundler/gems/discordrb-1cd5603d23e0/lib/discordrb/gateway.rb:579:in `connect'
[ERROR : websocket @ 2022-10-16 15:22:46.661] /usr/local/rvm/gems/ruby-3.1.2/bundler/gems/discordrb-1cd5603d23e0/lib/discordrb/gateway.rb:473:in `block in connect_loop'
[ERROR : websocket @ 2022-10-16 15:22:46.661] /usr/local/rvm/gems/ruby-3.1.2/bundler/gems/discordrb-1cd5603d23e0/lib/discordrb/gateway.rb:472:in `loop'
[ERROR : websocket @ 2022-10-16 15:22:46.661] /usr/local/rvm/gems/ruby-3.1.2/bundler/gems/discordrb-1cd5603d23e0/lib/discordrb/gateway.rb:472:in `connect_loop'
[ERROR : websocket @ 2022-10-16 15:22:46.661] /usr/local/rvm/gems/ruby-3.1.2/bundler/gems/discordrb-1cd5603d23e0/lib/discordrb/gateway.rb:168:in `block in run_async'
[ERROR : websocket @ 2022-10-16 15:25:34.644] The websocket connection has closed: (no information)
[INFO : websocket @ 2022-10-16 15:25:34.644] Instant reconnection flag was set - reconnecting right away
[INFO : websocket @ 2022-10-16 15:25:34.984] Resumed

looks like added_members and removed_member_ids falls back to empty array here in thread.rb, but this code in bot.rb is still accessing the data hash directly which can result in these being nil and causing the error.

The closed connection happens a few minutes later - I was assuming it was related, but it may not be.


Environment

ubuntu 20.0.4

Ruby version:

3.1.2

Discordrb version:

specs:
discordrb (3.4.2)
discordrb-webhooks (~> 3.4.2)
ffi (>= 1.9.24)
opus-ruby
rest-client (>= 2.0.0)
websocket-client-simple (>= 0.3.0)
discordrb-webhooks (3.4.2)
rest-client (>= 2.0.0)

@Daniel-Worrall
Copy link
Member

Introduced in #141, these fields are optional.

Will send a PR

@holdank
Copy link
Author

holdank commented Oct 17, 2022

Ah i see i had the flow backwards - thanks for taking a look.

Dakurei added a commit to Dakurei/discordrb that referenced this issue Apr 25, 2023
  Resolves issues with Threads Events that have been reported on the Discord
  By the way, solves issue shardlab#186, and closes pull request shardlab#187
swarley pushed a commit that referenced this issue Apr 25, 2023
Resolves issues with Threads Events that have been reported on the Discord
  By the way, solves issue #186, and closes pull request #187
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants