-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[Fix #11034] Fix hang when using --stderr
in server mode
#11060
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
Conversation
I'm not sure whether it's the better solution for the issue. This patch solves the unexpected pause issue, but
% bundle exec rubocop -h
(snip)
--stderr Write all output to stderr except for the
autocorrected source. This is especially useful
when combined with --autocorrect and --stdin. Below is a run without server mode, but same results would have been expected with server mode: % cat example.rb
puts "hello"
% bundle exec rubocop --stderr example.rb -a 2> /tmp/11034.log
% cat /tmp/11034.log
(snip)
RSpec/Rails/AvoidSetupHook: # new in 2.4
Enabled: true
RSpec/Rails/HaveHttpStatus: # new in 2.12
Enabled: true
For more information: https://docs.rubocop.org/rubocop/versioning.html
Inspecting 1 file
C
Offenses:
example.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
puts 'hello'
^
example.rb:1:6: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
puts "hello"
^^^^^^^
1 file inspected, 2 offenses detected, 1 offense corrected, 1 more offense can be corrected with `rubocop -A` Unexpected behavior still displays in the console when the server is enabled: % bundle exec rubocop --start-server
RuboCop server starting on 127.0.0.1:50281.
% bundle exec rubocop --stderr example.rb -a 2> /tmp/11034.log
(snip)
RSpec/Rails/AvoidSetupHook: # new in 2.4
Enabled: true
RSpec/Rails/HaveHttpStatus: # new in 2.12
Enabled: true
For more information: https://docs.rubocop.org/rubocop/versioning.html
Inspecting 1 file
C
Offenses:
example.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
puts 'hello'
^
example.rb:1:6: C: [Corrected] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
puts "hello"
^^^^^^^
1 file inspected, 2 offenses detected, 1 offense corrected, 1 more offense can be corrected with `rubocop -A` Even with server mode enabled, it would be expected to be redirected as stderr. |
@koic I think I managed to find a working implementation for combining I otherwise considered sending both streams through the socket by using a dedicated separation line (in the likes of |
I have confirmed that the redirected file is empty due to an unexpected behavior. % bundle exec rubocop --start-server
RuboCop server starting on 127.0.0.1:64200.
% bundle exec rubocop --stderr example.rb -a 2> /tmp/11034.log
% cat /tmp/11034.log # empty Can you check and add a test for the above case? |
stderr output was indeed missing because I had accidentally deleted https://github.com/rubocop/rubocop/pull/11060/files#diff-f3ac671b93c53d20faa674a2f9d4fc95517b7306a1a1ac5eb7b8619a731310f9R26 while doing some cleanup - should be all good now |
Should I add a changelog entry about support for |
Yes. Please add a changelog about this fixing! 👍 |
Great! Thanks! |
Happy to contribute 🥳 |
I would like to report the error related to this changes: if the exception happen on then there is
|
In ruby 3.3.6 the
I believe it is fixed in #13379 |
Yes, that PR should fix it. |
I was able to write a reproduction test case for this bug.
It seemed a bit more intricate than the original issue description as the hanging seem to only happen when cache is at play (hence having to run the command twice in the reproduction test).
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.