Address already in use - connect(2) for flatware-sink (Errno::EADDRINUSE)
After running bundle exec flatware rspec I killed the process with a ctrl+c while it was in the middle of spinning up and now I'm getting Address already in use - connect(2) for flatware-sink (Errno::EADDRINUSE) anytime I try to run it again.
I've tried a few things including running flatware clear but to no avail. I'm wondering if you have any troubleshooting tips or if you've run into this yourself.
It's a lovely gem and I'm really hoping I can get this figured out because it was going so well there for a minute. 😄
I'm on an Apple M1 Pro with macOS Ventura 13.1 and I'm running ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21].
Here is the backtrace:
.../.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/drb/unix.rb:41:in `initialize': Address already in use - connect(2) for flatware-sink (Errno::EADDRINUSE)
.../.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/drb/unix.rb:41:in `open'
.../.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/drb/unix.rb:41:in `open_server'
.../.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/drb/drb.rb:766:in `block in open_server'
.../.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/drb/drb.rb:764:in `each'
.../.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/drb/drb.rb:764:in `open_server'
.../.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/drb/drb.rb:772:in `open_server'
.../.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/drb/drb.rb:1462:in `initialize'
.../.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/drb/drb.rb:1763:in `new'
.../.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/drb/drb.rb:1763:in `start_service'
.../.rvm/gems/ruby-3.1.2/gems/flatware-2.1.0/lib/flatware/sink.rb:36:in `start'
.../.rvm/gems/ruby-3.1.2/gems/flatware-2.1.0/lib/flatware/sink.rb:9:in `start_server'
.../.rvm/gems/ruby-3.1.2/gems/flatware-2.1.0/lib/flatware/cli.rb:59:in `start_sink'
.../.rvm/gems/ruby-3.1.2/gems/flatware-rspec-2.1.0/lib/flatware/rspec/cli.rb:27:in `rspec'
.../.rvm/gems/ruby-3.1.2/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
.../.rvm/gems/ruby-3.1.2/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
.../.rvm/gems/ruby-3.1.2/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
.../.rvm/gems/ruby-3.1.2/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
.../.rvm/gems/ruby-3.1.2/gems/flatware-2.1.0/bin/flatware:6:in `<top (required)>'
.../.rvm/gems/ruby-3.1.2/bin/flatware:25:in `load'
.../.rvm/gems/ruby-3.1.2/bin/flatware:25:in `<main>'
.../.rvm/gems/ruby-3.1.2/bin/ruby_executable_hooks:22:in `eval'
.../.rvm/gems/ruby-3.1.2/bin/ruby_executable_hooks:22:in `<main>'
@rmontgomery429 hey there thanks for the kind words! there should be a socket file in your cwd called flatware-sink. Must be some exit condition in which it doesn't get cleaned up. removing it manually should do the trick: rm flatware-sink.
Should probably add that to flatware clear. And, ideally figure out how to close the pipe reliably when killed.
In one case for us, an OOM caused by webpack(er) caused the file to not be removed (which makes complete sense). Perhaps checking that file for locking instead of existence could help soften this issue?
I'd love to see a PR that does any / all of the following.
- deletes the socket file as a part of
flatware clear - adds a
forceflag to delete it on start if it's already there - asks the user interactively if they want to delete the previous socket file.
Also, an at_exit { DRb.stop_service } in Sink could help prevent.