File tree 1 file changed +16
-4
lines changed
1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -41,10 +41,22 @@ def teardown
41
41
make_request ( "shutdown" )
42
42
send_request ( "exit" )
43
43
44
- # Make sure IOs are closed
45
- @stdin . close
46
- @stdout . close
47
- @stderr . close
44
+ # Give the server some time to process the "shutdown" and "exit" messages before
45
+ # closing the streams. Otherwise, it's possible the server misses one or both of them
46
+ # depending on what it's currently processing. This is wrapped in a timeout in case
47
+ # the server fails to process the messages.
48
+ begin
49
+ Timeout . timeout ( 60 ) do
50
+ sleep ( 0.010 ) while @wait_thr . alive?
51
+ end
52
+ rescue Timeout ::Error
53
+ raise "The LSP server failed to shut down cleanly."
54
+ ensure
55
+ # Make sure IOs are closed
56
+ @stdin . close
57
+ @stdout . close
58
+ @stderr . close
59
+ end
48
60
49
61
# Make sure the exit status is zero
50
62
assert_equal ( 0 , @wait_thr . value )
You can’t perform that action at this time.
0 commit comments