File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ module Sentry
5050
5151 THREAD_LOCAL = :sentry_hub
5252
53+ MUTEX = Mutex . new
54+
5355 class << self
5456 # @!visibility private
5557 def exception_locals_tp
@@ -226,6 +228,7 @@ def add_attachment(**opts)
226228 # @yieldparam config [Configuration]
227229 # @return [void]
228230 def init ( &block )
231+ @mutex = MUTEX
229232 config = Configuration . new
230233 yield ( config ) if block_given?
231234 config . detect_release
@@ -275,8 +278,10 @@ def close
275278
276279 @background_worker . shutdown
277280
278- @main_hub = nil
279- Thread . current . thread_variable_set ( THREAD_LOCAL , nil )
281+ MUTEX . synchronize do
282+ @main_hub = nil
283+ Thread . current . thread_variable_set ( THREAD_LOCAL , nil )
284+ end
280285 end
281286
282287 # Returns true if the SDK is initialized.
@@ -303,7 +308,7 @@ def csp_report_uri
303308 #
304309 # @return [Hub]
305310 def get_main_hub
306- @main_hub
311+ MUTEX . synchronize { @main_hub }
307312 end
308313
309314 # Takes an instance of Sentry::Breadcrumb and stores it to the current active scope.
You can’t perform that action at this time.
0 commit comments