File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,14 @@ def run_bundle_install(bundle_gemfile = @gemfile)
234
234
# If no error occurred, then clear previous errors
235
235
@error_path . delete if @error_path . exist?
236
236
$stderr. puts ( "Ruby LSP> Composed bundle installation complete" )
237
+ rescue Errno ::EPIPE
238
+ # If the $stderr pipe was closed by the client, for example when closing the editor during running bundle
239
+ # install, we don't want to write the error to a file or else we will report to telemetry on the next launch and
240
+ # it does not represent an actual error.
241
+ #
242
+ # This situation may happen because while running bundle install, the server is not yet ready to receive
243
+ # shutdown requests and we may continue doing work until the process is killed.
244
+ @error_path . delete if @error_path . exist?
237
245
rescue => e
238
246
# Write the error object to a file so that we can read it from the parent process
239
247
@error_path . write ( Marshal . dump ( e ) )
Original file line number Diff line number Diff line change @@ -914,6 +914,28 @@ def test_ignores_bundle_package
914
914
end
915
915
end
916
916
917
+ def test_is_resilient_to_pipe_being_closed_by_client_during_compose
918
+ Dir . mktmpdir do |dir |
919
+ Dir . chdir ( dir ) do
920
+ File . write ( File . join ( dir , "gems.rb" ) , <<~GEMFILE )
921
+ source "https://rubygems.org"
922
+ gem "irb"
923
+ GEMFILE
924
+
925
+ Bundler . with_unbundled_env do
926
+ capture_subprocess_io do
927
+ system ( "bundle install" )
928
+
929
+ compose = RubyLsp ::SetupBundler . new ( dir , launcher : true )
930
+ compose . expects ( :run_bundle_install_directly ) . raises ( Errno ::EPIPE )
931
+ compose . setup!
932
+ refute_path_exists ( File . join ( dir , ".ruby-lsp" , "install_error" ) )
933
+ end
934
+ end
935
+ end
936
+ end
937
+ end
938
+
917
939
private
918
940
919
941
def with_default_external_encoding ( encoding , &block )
You can’t perform that action at this time.
0 commit comments