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

Handle "Nick in use" notice in IRC adapter. #113

Merged
merged 1 commit into from
Oct 29, 2019
Merged

Handle "Nick in use" notice in IRC adapter. #113

merged 1 commit into from
Oct 29, 2019

Conversation

sarg
Copy link
Contributor

@sarg sarg commented Oct 19, 2019

irclj uses separate thread for connection. Whenever "nick in use" occurs it calls callback and then throws Exception which stops the thread. (https://github.com/Raynes/irclj/blob/f230935cd94dc1c86ffb6677c1b6bb8675d3df94/src/irclj/process.clj#L91)

So in order to recover this siutation I have to stop/start adapter.

@sarg sarg requested a review from devth as a code owner October 19, 2019 14:53
@codecov
Copy link

codecov bot commented Oct 19, 2019

Codecov Report

Merging #113 into master will increase coverage by <.01%.
The diff coverage is 41.46%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #113      +/-   ##
==========================================
+ Coverage   43.64%   43.64%   +<.01%     
==========================================
  Files          90       90              
  Lines        3590     3622      +32     
  Branches      166      166              
==========================================
+ Hits         1567     1581      +14     
- Misses       1857     1875      +18     
  Partials      166      166
Impacted Files Coverage Δ
src/yetibot/core/adapters/irc.clj 27.23% <41.46%> (+2.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b79014...492c487. Read the comment docs.

Copy link
Member

@devth devth left a comment

Choose a reason for hiding this comment

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

I tested this by configuring my local Yetibot to join IRC using my own username (which is taken). The strange thing is it only re-joins 2 out of the 3 channels that it was supposed to after reconnect. Are you seeing this? Or are you testing it another way?

I'm not totally sure what's going on with this behavior, but the fix was to add (reset! current-channels #{}) to stop:

(defn stop
  "Kill the irc conection"
  [{:keys [current-channels conn]}]
  (when-let [c @conn] (irc/kill c))
  (reset! current-channels #{})
  (reset! conn nil))

This makes sense, as it will need to re-join all channels after that reconnect.

@sarg
Copy link
Contributor Author

sarg commented Oct 23, 2019

Yeah, I also have no clue why that is happening. I was testing only the reconnection part though. I've amended commit with your suggestion.

@devth
Copy link
Member

devth commented Oct 23, 2019

@sarg awesome, thanks!

@devth devth self-requested a review October 23, 2019 21:25
Copy link
Member

@devth devth left a comment

Choose a reason for hiding this comment

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

Oops, Unable to resolve symbol: current-channels in this context after latest change.

stop should be:

(defn stop
  "Kill the irc conection"
  [{:keys [current-channels conn]}]
  (when-let [c @conn] (irc/kill c))
  (reset! current-channels #{})
  (reset! conn nil))

@devth devth self-requested a review October 23, 2019 21:35
@sarg
Copy link
Contributor Author

sarg commented Oct 29, 2019

I've pushed the fix

Copy link
Member

@devth devth left a comment

Choose a reason for hiding this comment

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

@sarg thanks!

@devth devth merged commit 026a04c into yetibot:master Oct 29, 2019
@sarg sarg deleted the iss-457 branch October 29, 2019 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants