@@ -150,7 +150,17 @@ defmodule ElixirLS.LanguageServer.Tracer do
150
150
% { }
151
151
)
152
152
153
- Logger . info ( "Terminating #{ __MODULE__ } : #{ message } " )
153
+ JsonRpc . show_message (
154
+ :error ,
155
+ "Tracer process exited due to critical error"
156
+ )
157
+
158
+ Logger . error ( "Terminating #{ __MODULE__ } : #{ message } " )
159
+
160
+ unless Application . get_env ( :language_server , :test_mode ) do
161
+ Process . sleep ( 2000 )
162
+ System . halt ( 1 )
163
+ end
154
164
end
155
165
end
156
166
@@ -172,14 +182,26 @@ defmodule ElixirLS.LanguageServer.Tracer do
172
182
table_name = table_name ( table )
173
183
path = dets_path ( project_dir , table )
174
184
175
- opts = [ file: path |> String . to_charlist ( ) , auto_save: 60_000 ]
185
+ opts = [ file: path |> String . to_charlist ( ) , auto_save: 60_000 , repair: true ]
176
186
177
187
:ok = path |> Path . dirname ( ) |> File . mkdir_p ( )
178
188
179
189
case :dets . open_file ( table_name , opts ) do
180
190
{ :ok , _ } ->
181
191
:ok
182
192
193
+ { :error , { :needs_repair , _ } = reason } ->
194
+ Logger . warning ( "Unable to open DETS #{ path } : #{ inspect ( reason ) } " )
195
+ File . rm_rf! ( path )
196
+
197
+ { :ok , _ } = :dets . open_file ( table_name , opts )
198
+
199
+ { :error , { :repair_failed , _ } = reason } ->
200
+ Logger . warning ( "Unable to open DETS #{ path } : #{ inspect ( reason ) } " )
201
+ File . rm_rf! ( path )
202
+
203
+ { :ok , _ } = :dets . open_file ( table_name , opts )
204
+
183
205
{ :error , { :not_a_dets_file , _ } = reason } ->
184
206
Logger . warning ( "Unable to open DETS #{ path } : #{ inspect ( reason ) } " )
185
207
File . rm_rf! ( path )
0 commit comments