slack-ruby-client icon indicating copy to clipboard operation
slack-ruby-client copied to clipboard

Set X-Slack-No-Retry header during Slack timeout

Open neto-marc opened this issue 6 years ago • 2 comments

When using the webclient through AWS API gateway, there are often delays which cause slack to return "X-Slack-Retry-Reason"=>"http_timeout" even though the POST has been made successfully (the bot writes to slack).

Is there a way to set the X-Slack-No-Retry: 1 on the webclient config in order to prevent the bot attempting the same call multiple times even though successful?

neto-marc avatar Jun 17 '19 03:06 neto-marc

The connection is setup here for the web client. It's private. We don't seem to expose arbitrary headers or a connection editing mechanism.

Try client.send(:connection).headers['X-Slack-No-Retry'] = 1 as a workaround?

I'd like this implemented properly if you want to give it a stab. I suggest exposing the entire connection object.

Slack::Web::Client.configure do |config|
  config.connection do |c|
     c.use Faraday::Request::OAuth # yields during connection creation
  end
  # or
  config.connection.headers[...] = ...
end

dblock avatar Jun 17 '19 13:06 dblock

For the specific X-Slack-Retry-Reason error I would also appreciate a custom exception like we do for rate limiting.

dblock avatar Jun 17 '19 13:06 dblock