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

[Fix #11984] Add configurable server idle timeout #11985

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Palladinium
Copy link

@Palladinium Palladinium commented Jun 26, 2023

This adds support for a new environment variable when running rubocop in server mode, RUBOCOP_SERVER_IDLE_TIMEOUT.

When the variable is set, it's interpreted as a number of seconds, and the server will automatically exit if that many seconds pass without receiving any connections.

I'm hesitant to add tests since they'll likely be timing-sensitive (read: inconsistent) and/or might slow down the suite with sleeps.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 26, 2023

I'll defer to @koic on this one, but I'll mention that it might be nice to be able to set the timeout without with some command-line flag as well. (it would take precedence over the env var)

@bbatsov bbatsov requested a review from koic July 1, 2023 04:33
@koic
Copy link
Member

koic commented Jul 6, 2023

I'm hesitant to add tests since they'll likely be timing-sensitive (read: inconsistent) and/or might slow down the suite with sleeps.

It looks good to have a test that uses stubs and mocks. Especially the behavior around the IO::WaitReadable exception handling.

# JSON format does not expected output message when IDE integration with server mode.
# See: https://github.com/rubocop/rubocop/issues/11164
return if use_json_format?
return nil if use_json_format?
Copy link
Member

Choose a reason for hiding this comment

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

Is this change intentional?

Copy link
Author

Choose a reason for hiding this comment

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

I think it was just force of habit, I forgot the two are equivalent. I'll revert it since the older line is more concise.

@Palladinium Palladinium marked this pull request as draft July 6, 2023 09:35
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

3 participants