Skip to content

Commit

Permalink
Fully unload add-ons under a mutex when shutting down
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Dec 10, 2024
1 parent 7f641ba commit 5c300ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/ruby_lsp/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ def load_addons(global_state, outgoing_queue, include_project_addons: true)
errors
end

# Unloads all add-ons. Only intended to be invoked once when shutting down the Ruby LSP server
sig { void }
def unload_addons
@addons.each(&:deactivate)
@addons.clear
@addon_classes.clear
@file_watcher_addons.clear
end

# Get a reference to another add-on object by name and version. If an add-on exports an API that can be used by
# other add-ons, this is the way to get access to that API.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_lsp/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ def workspace_dependencies(message)

sig { override.void }
def shutdown
Addon.addons.each(&:deactivate)
@mutex.synchronize { Addon.unload_addons }
end

sig { void }
Expand Down

0 comments on commit 5c300ba

Please sign in to comment.