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

WIP: Emit debugging events #567

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/bot.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ class SlackBot extends Adapter
# NOTE: should rate limit errors also bubble up?
if error.code isnt -1
@robot.emit "error", error
else
@robot.emit "slack-rate-limit"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it took quite a bit of detective work, but it turns out that we don't know of any code that triggers the "error" event on the RtmClient, which is the only code path that results in this method ever getting called.

it seems like the comparison of code to -1 is remnants from the v3.x series of hubot-slack, which used the v1.x series of @slack/client, which would have emitted a "error" event.

therefore, i don't think this code is worth merging, because it would just become even more misleading.


###*
# Incoming Slack event handler
Expand Down
5 changes: 4 additions & 1 deletion src/client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,13 @@ class SlackClient
thread_ts: envelope.message?.thread_ts

if typeof message isnt "string"
@web.chat.postMessage(room, message.text, _.defaults(message, options))
messageOptions = _.defaults(message, options)
@robot.emit "postMessage", room, message.text, messageOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the goal is just to understand when chat.postMessage is called, then i don't think emitting on the robot is appropriate.

instead, i think the goal should be to turn on more logging, specifically for the WebClient. currently, there's a pattern established to set more options on the RtmClient using the HUBOT_SLACK_RTM_CLIENT_OPTS environment variable. so an alternative that i would favor is to introduce a HUBOT_SLACK_WEB_CLIENT_OPTS environment variable that can be used to set the logLevel to "debug" (and any of the other options).

what do you think?

@web.chat.postMessage(room, message.text, messageOptions)
.catch (error) =>
@robot.logger.error "SlackClient#send() error: #{error.message}"
else
@robot.emit "postMessage", room, message, options
@web.chat.postMessage(room, message, options)
.catch (error) =>
@robot.logger.error "SlackClient#send() error: #{error.message}"
Expand Down