Skip to content

Fallback to NullClient if initializing server fails #266

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

Merged
merged 2 commits into from
Feb 22, 2024

Conversation

vinistock
Copy link
Member

Closes #265

Currently, if we fail to initialize the server, we show errors every time hover occurs. The reason is because initialize raises, meaning the memoized client is never set and thus causing us to try to initialized it again on every hover.

Since the client is bound to be used everywhere in this addon, I think the easiest way of handling it is falling back to a NullClient that simply no-ops most operations. That way, we don't have to spread a bunch of conditionals everywhere in the code.

Manual tests

  1. On this branch, change the Open3.popen3 command from bin/rails to something that doesn't exist. Like non-existing-command-test.
  2. Reload VS Code
  3. Try to hover on a constant
  4. Verify that an error gets printed to the output tab
  5. Hover again on a constant
  6. Verify nothing gets printed

@vinistock vinistock added the bugfix This PR fixes an existing bug label Feb 20, 2024
@vinistock vinistock self-assigned this Feb 20, 2024
@vinistock vinistock requested a review from a team as a code owner February 20, 2024 22:34
@vinistock vinistock requested review from andyw8 and egiurleo February 20, 2024 22:34
@vinistock vinistock force-pushed the vs/fallback_to_null_client branch 4 times, most recently from d1d6806 to c46b664 Compare February 21, 2024 21:09
@vinistock vinistock force-pushed the vs/fallback_to_null_client branch 2 times, most recently from 087a36e to f3cceb8 Compare February 21, 2024 21:58
@vinistock vinistock force-pushed the vs/fallback_to_null_client branch from f3cceb8 to b010c6a Compare February 22, 2024 14:53
@vinistock vinistock requested a review from st0012 February 22, 2024 14:53
@vinistock vinistock merged commit f4f37b4 into main Feb 22, 2024
@vinistock vinistock deleted the vs/fallback_to_null_client branch February 22, 2024 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rails client should become no-op if booting Rails runner fails
3 participants