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

undefined method `Async' for #<Slack::RealTime::Concurrency::Async::Socket> (NoMethodError) #272

Closed
christiannelson opened this issue May 30, 2019 · 8 comments
Labels

Comments

@christiannelson
Copy link

The project https://github.com/carbonfive/socrates uses slack-ruby-client.

When using version slack-ruby-client (0.14.2), I get this error when starting the bot:

Traceback (most recent call last):
	1: from /Users/christian/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/slack-ruby-client-0.14.2/lib/slack/real_time/concurrency/async.rb:23:in `block in start_async'
/Users/christian/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/slack-ruby-client-0.14.2/lib/slack/real_time/concurrency/async.rb:28:in `start_reactor': undefined method `Async' for #<Slack::RealTime::Concurrency::Async::Socket:0x000000010ec8b5e0> (NoMethodError)

Looking at

, it seems to me that Async will resolve to the module Async on line 8 of the same file, instead of the intended version (https://github.com/socketry/async/blob/master/lib/async.rb#L33). The error I'm seeing (above) suggests that's what's happening.

Reverting to 0.14.1 resolves the problem.

@christiannelson
Copy link
Author

Adding require 'async' at the top of concurrency/async.rb resolves the NoMethodError, but then results in this error:

<Async::Task:0x8505b1b4 client run-loop failed>
      |   NoMethodError: undefined method `tcp' for Async::IO::Endpoint:Class
      |   Did you mean?  tap
      |   → /Users/christian/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/slack-ruby-client-0.14.2/lib/slack/real_time/concurrency/async.rb:115 in `build_endpoint'
      |     /Users/christian/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/slack-ruby-client-0.14.2/lib/slack/real_time/concurrency/async.rb:121 in `connect_socket'
      |     /Users/christian/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/slack-ruby-client-0.14.2/lib/slack/real_time/concurrency/async.rb:125 in `connect'
      |     /Users/christian/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/slack-ruby-client-0.14.2/lib/slack/real_time/socket.rb:31 in `connect!'
      |     /Users/christian/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/slack-ruby-client-0.14.2/lib/slack/real_time/concurrency/async.rb:76 in `connect!'
      |     /Users/christian/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/slack-ruby-client-0.14.2/lib/slack/real_time/client.rb:83 in `run_loop'
      |     /Users/christian/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/slack-ruby-client-0.14.2/lib/slack/real_time/concurrency/async.rb:50 in `block (2 levels) in start_reactor'
      |     /Users/christian/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/async-1.17.1/lib/async/task.rb:204 in `block in make_fiber'

@dblock
Copy link
Collaborator

dblock commented May 30, 2019

We always properly refer to ::Async, so this seems strange. Is there a smaller repro or can I just bundle update socrates?

@dblock dblock added the bug? label May 30, 2019
@christiannelson
Copy link
Author

christiannelson commented May 30, 2019

@dblock Socrates, while intended to be a library, also includes a mini chatbot example which is easy to fire up for demo purposes. So, here are 2 ways to quickly reproduce the error...

  1. Installing the Socrates gem...
gem install socrates
SLACK_API_TOKEN=<SLACK TOKEN> socrates -a slack run
  1. Cloning the Socrates repo (requires you to have ruby 2.6.3 installed)...
git clone git@github.com:carbonfive/socrates.git
cd socrates
bundle update
SLACK_API_TOKEN=<SLACK TOKEN> ./exe/socrates -a slack run

The second version might result in newer versions of gem dependencies, but I'm not 100% certain. I think it might depend on what is already installed.

Thanks for looking! Please don't hesitate to ask if I can help debug on my end.

@christiannelson
Copy link
Author

I tried changing the reference to ::Async do, but that's not valid ruby. I then tried ::Async::Reactor.run do which is valid ruby and should be the same thing, but failed in another way (which I don't recall at the moment).

@christiannelson
Copy link
Author

I tried changing the reference to ::Async do, but that's not valid ruby. I then tried ::Async::Reactor.run do which is valid ruby and should be the same thing, but failed in another way (which I don't recall at the moment).

Using ::Async::Reactor.run do... results in a uninitialized constant Async::Reactor (NameError).

Adding require 'async/reactor' to the top of the file, then results in:

<Async::Task:0x837986e0 client run-loop failed>
NoMethodError: undefined method `tcp' for Async::IO::Endpoint:Class
      |   Did you mean?  tap
      |   → /Users/christian/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/slack-ruby-client-0.14.2/lib/slack/real_time/concurrency/async.rb:115 in `build_endpoint'

I didn't jump any further down the rabbit hole.

@dblock
Copy link
Collaborator

dblock commented Jul 20, 2019

This is because async-websocket 0.9 has a backwards incompatible set of changes from 0.8. For now the best solution is to lock down to 0.8.0. I opened #282 to upgrade.

@DannyBen
Copy link

Not sure if this is still active (and not just open), but for what its worth - I used to have this problem also (with my slacktail gem), but now testing it with 0.15.1, it seems to be working fine.

@dblock
Copy link
Collaborator

dblock commented Dec 21, 2020

We locked it in #283. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants