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

rescue Errno::EBADF when closing pipe #92

Merged
merged 1 commit into from
Feb 6, 2022
Merged

rescue Errno::EBADF when closing pipe #92

merged 1 commit into from
Feb 6, 2022

Conversation

estraph
Copy link
Contributor

@estraph estraph commented Feb 2, 2022

It's possible for the pipe to be invalid by the time we attempt to close it, causing it to raise Errno::EBADF:

E, [2022-02-02T15:56:26.134134 #2412] ERROR -- : Exception rescued in listen-worker_thread:
Errno::EBADF: Bad file descriptor
/Users/raph/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rb-fsevent-0.10.4/lib/rb-fsevent/fsevent.rb:90:in `close'
/Users/raph/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rb-fsevent-0.10.4/lib/rb-fsevent/fsevent.rb:90:in `stop'
/Users/raph/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rb-fsevent-0.10.4/lib/rb-fsevent/fsevent.rb:84:in `run'
/Users/raph/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/listen-3.4.1/lib/listen/adapter/darwin.rb:49:in `block in _run'
/Users/raph/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/listen-3.4.1/lib/listen/thread.rb:26:in `rescue_and_log'
/Users/raph/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/listen-3.4.1/lib/listen/thread.rb:18:in `block in new'
--- Thread.new ---
/Users/raph/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/listen-3.4.1/lib/listen/adapter/darwin.rb:49:in `_run'
/Users/raph/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/listen-3.4.1/lib/listen/adapter/base.rb:79:in `block in start'
/Users/raph/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/listen-3.4.1/lib/listen/thread.rb:26:in `rescue_and_log'
/Users/raph/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/listen-3.4.1/lib/listen/thread.rb:18:in `block in new'

I don't fully understand the circumstances which lead to this but it happens to me and others on my team regularly (Ruby 3.0.3, macOS Monterey + Big Sur, running a Rails 6.1 app with puma 5.2.2). Possibly similar to #40

It does not appear to have any negative effects and since we're closing the pipe at this point anyway I don't think we can do much about it - the error output is distracting and doesn't seem actionable. Hence I suggest we rescue Errno::EBADF when closing the pipe just like we do for IOError.

@estraph
Copy link
Contributor Author

estraph commented Feb 2, 2022

CC @thibaudgg (please forgive the ping - hoping for some human attention given this repo hasn't seen a lot of activity lately)

@thibaudgg thibaudgg merged commit 30bfe52 into guard:master Feb 6, 2022
@thibaudgg
Copy link
Member

Hey @estraph, thanks a lot for your PR, v0.11.1 has been released.

@estraph estraph deleted the raph/rescue-errbadf-on-close branch February 8, 2022 18:38
@estraph
Copy link
Contributor Author

estraph commented Feb 8, 2022

Thanks a lot for the quick turnaround @thibaudgg 💪

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.

None yet

2 participants