slack-ruby/slack-ruby-client

Random Slack::Web::Api::Errors::TimeoutError on chat_update

benoittgt opened this issue · 3 comments

Hello

I do

sentry_client.chat_update(
      channel: channel,
      ts: ts,
      attachments: attachments,
      username: SLACK_USERNAME,
      icon_emoji: SLACK_ICON_EMOJI,
    )

And I see in logs that we do a

def conversations_list(options = {})

that sometimes lead to timeout.

The thing is I have around between 100 to 250 timeouts per day even with:

Slack::Web::Client.configure do |config|
  config.timeout = 40
  config.open_timeout = 40
end

And all my Slack calls are made from Sidekiq worker with 10 retries.

I am wondering if I am the only one?

What's the channel argument? I bet it's a channel name which is being resolved to a channel ID by enumerating all channels, which is very slow. It calls

options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
, which lands in
id_for :channel, name, '#', :conversations_list, :channels, 'channel_not_found'
which then calls conversations_list.

Store and use the channel ID.

If this is your issue, maybe we should add something to the documentation in https://github.com/slack-ruby/slack-ruby-client#get-channel-info? Care to do it?

Hello

Thanks a lot for the quick answer. Yes it is a channel name. Sometimes I have also the issue with auth_test but less often.

I will open a PR to add some documentation on this aspect, and will store locally the channel id when I have it in my app.

Closing this since the timeout is "expected".