Skip to content

Commit 628add4

Browse files
authored
No-op if runner client is null (#2172)
### Motivation When we fail to boot the Rails runtime server, the runner client becomes an instance of `NullClient`, in which all operations are no-op. There's no point in trying to run any DSL generation in that case because every notification will do nothing. ### Implementation Started returning early if the client is not an instance of the concrete runner client.
2 parents e64a3cf + 6ec6fab commit 628add4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/ruby_lsp/tapioca/addon.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def initialize
2525
super
2626

2727
@global_state = T.let(nil, T.nilable(RubyLsp::GlobalState))
28-
@rails_runner_client = T.let(nil, T.nilable(RubyLsp::Rails::RunnerClient))
28+
@rails_runner_client = T.let(Rails::NullClient.new, RubyLsp::Rails::RunnerClient)
2929
@index = T.let(nil, T.nilable(RubyIndexer::Index))
3030
@file_checksums = T.let({}, T::Hash[String, String])
3131
@lockfile_diff = T.let(nil, T.nilable(String))
@@ -81,7 +81,7 @@ def version
8181
sig { params(changes: T::Array[{ uri: String, type: Integer }]).void }
8282
def workspace_did_change_watched_files(changes)
8383
return unless T.must(@global_state).enabled_feature?(:tapiocaAddon)
84-
return unless @rails_runner_client # Client is not ready
84+
return unless @rails_runner_client.connected?
8585

8686
has_route_change = T.let(false, T::Boolean)
8787
has_fixtures_change = T.let(false, T::Boolean)

0 commit comments

Comments
 (0)