tonyvanriet / lunch-bot

A Slack bot that manages group lunch activity
MIT License
26 stars 5 forks source link

Failure when responding to the `choose` command #12

Closed the-mikedavis closed 4 years ago

the-mikedavis commented 5 years ago
Exception trying to handle slack message
{:source_team "T88PYL9GT", :event_ts "1563457866.000800", :channel "D8LKMURNE", :type "message", :ts "1563457866.000800", :team "T88PYL9GT", :client_msg_id "636a44c8-0b41-4b55-8530-6eb72e98ec62", :user_team "T88PYL9GT", :user "U88AYD6DP", :suppress_notification false, :text "choose BW3"}.
#<TimeoutException java.util.concurrent.TimeoutException: timed out after 60000.0 milliseconds>
java.util.concurrent.TimeoutException: timed out after 60000.0 milliseconds
 at manifold.deferred$timeout_BANG_$fn__3247.invoke (deferred.clj:1082)
    manifold.time$eval2672$in__2675$f__2676.invoke (time.clj:144)
    clojure.lang.AFn.run (AFn.java:22)
    java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
    java.util.concurrent.FutureTask.run (FutureTask.java:266)
    java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201 (ScheduledThreadPoolExecutor.java:180)
    java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:293)
    java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
    manifold.utils$thread_factory$reify__2552$fn__2554.invoke (utils.clj:25)
    clojure.lang.AFn.run (AFn.java:22)
    java.lang.Thread.run (Thread.java:748)

after choose, the bot does some reconnecting for a while and then can take today and friends

tonyvanriet commented 5 years ago

theorizing that the web/channels-setTopic external call is slow enough to time out the socket, causing a reconnect which may result in multi-blanche. no strong evidence, just seems like a likely candidate after skimming the code.

https://github.com/tonyvanriet/lunch-bot/blob/ac8c296f5d1760bc14789b66e221306a22ae7aab/src/lunch_bot/core.clj#L58

to test it, should remove this and the setTopic call for the bought command, though we don't use that these days.

tonyvanriet commented 5 years ago

Commenting out some of the setTopic calls avoids the timeout, but now we're seeing a java NPE when executing the choose command.

{:source_team T1D2RFN9H, :event_ts 1563809481.007300, :channel D2BL4UD0V, :type message, :ts 1563809481.007300, :team T1D2RFN9H, :client_msg_id c7e40494-c72
9-4274-b91b-c38e357f02f7, :user_team T1D2RFN9H, :user U2A75S6A0, :suppress_notification false, :text choose hakkore}
----------------------------------------------------------------------------------------------------
Exception trying to handle slack message
{:source_team "T1D2RFN9H", :event_ts "1563809481.007300", :channel "D2BL4UD0V", :type "message", :ts "1563809481.007300", :team "T1D2RFN9H", :client_msg_id
"c7e40494-c729-4274-b91b-c38e357f02f7", :user_team "T1D2RFN9H", :user "U2A75S6A0", :suppress_notification false, :text "choose hakkore"}.
#<NullPointerException java.lang.NullPointerException>
java.lang.NullPointerException: null
 at clojure.string$replace.invoke (string.clj:99)
    clj_slack_client.rtm_transmit$linkify.invoke (rtm_transmit.clj:10)
    clj_slack_client.rtm_transmit$say_message.invoke (rtm_transmit.clj:37)
    lunch_bot.talk$say_message.invoke (talk.clj:236)
    lunch_bot.core$distribute_message.invoke (core.clj:44)
    lunch_bot.core$handle_message.invoke (core.clj:125)
    lunch_bot.core$eval9069$fn__9071.invoke (core.clj:138)
    clojure.lang.MultiFn.invoke (MultiFn.java:227)
    lunch_bot.core$try_handle_slack_event.invoke (core.clj:157)
    manifold.stream.Callback.put (stream.clj:432)
    ...
    ... more library stuff that's not lunch-bot
    ...
the-mikedavis commented 5 years ago

@tonyvanriet it's the text field with the doseq distribute in core.clj:125

the-mikedavis commented 5 years ago
(when (seq [])
  :ok)
;=> nil

gives the nil in lunch-bot.command.reply:17