From b8f56ea96972ec9b3e6028f1670f64c1377a10f9 Mon Sep 17 00:00:00 2001 From: pvincent Date: Wed, 25 Sep 2024 17:13:06 +0400 Subject: [PATCH] fix definable_listeners --- lib/live/definable.rb | 22 +++++++++------------- lib/semantic/abstract_formatter.rb | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/live/definable.rb b/lib/live/definable.rb index 1bbf4eb..5fd4348 100644 --- a/lib/live/definable.rb +++ b/lib/live/definable.rb @@ -1,6 +1,6 @@ require 'dotenv' -DEFINABLE_THREAD_GROUP ||= ThreadGroup.new # rubocop:disable Lint/OrAssignmentToConstant +# DEFINABLE_THREAD_GROUP ||= ThreadGroup.new DEFINABLE_LISTENERS ||= [] # rubocop:disable Lint/OrAssignmentToConstant module Live @@ -97,19 +97,15 @@ module Live end def start_listener - DEFINABLE_LISTENERS.each(&:stop) # FIXME: issue on stop after multiple reload!!! Learn mode about listener: #close + DEFINABLE_LISTENERS.each(&:stop) DEFINABLE_LISTENERS.clear - DEFINABLE_THREAD_GROUP.list.each(&:kill) - - DEFINABLE_THREAD_GROUP.add(Thread.new do - listener = Listen.to(Rails.root, only: /^\.env\.?/) do - @@class_origin.reload_from_env - rescue StandardError - nil - end - DEFINABLE_LISTENERS << listener - listener.start - end) + listener = Listen.to(Rails.root, only: /^\.env\.?/) do + @@class_origin.reload_from_env + rescue StandardError => e + logger.error('unable to reload from env', e) + end + listener.start + DEFINABLE_LISTENERS << listener end def typed_value(type, raw, default) diff --git a/lib/semantic/abstract_formatter.rb b/lib/semantic/abstract_formatter.rb index c31bd88..dead6d2 100644 --- a/lib/semantic/abstract_formatter.rb +++ b/lib/semantic/abstract_formatter.rb @@ -29,7 +29,7 @@ module Semantic clazz = colorize("#{exc.class}\n", color_map[:fatal]) message = colorize(exc.message.chomp(''), color_map[:error]) backtrace = exc.backtrace - stack = Helper.stackisize(*backtrace) + stack = Semantic::Helper.stackisize(*backtrace) ["#{clazz}#{message}", stack].compact.join("\n") end