From 318becbef65194ddc0639ec87bdf079e14420701 Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Wed, 8 May 2024 13:32:38 -0400 Subject: [PATCH] fix: Log warning if provided high client init timeout --- lib/ldclient-rb/ldclient.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/ldclient-rb/ldclient.rb b/lib/ldclient-rb/ldclient.rb index f3bb311a..51e5dfc7 100644 --- a/lib/ldclient-rb/ldclient.rb +++ b/lib/ldclient-rb/ldclient.rb @@ -124,13 +124,18 @@ def initialize(sdk_key, config = Config.default, wait_for_sec = 5) end ready = @data_source.start - if wait_for_sec > 0 - ok = ready.wait(wait_for_sec) - if !ok - @config.logger.error { "[LDClient] Timeout encountered waiting for LaunchDarkly client initialization" } - elsif !@data_source.initialized? - @config.logger.error { "[LDClient] LaunchDarkly client initialization failed" } - end + + return unless wait_for_sec > 0 + + if wait_for_sec > 60 + @config.logger.warn { "[LDClient] LDClient was instantiated with a timeout greater than 60 seconds. We recommend a timeout of less than 60 seconds." } + end + + ok = ready.wait(wait_for_sec) + if !ok + @config.logger.error { "[LDClient] Timeout encountered waiting for LaunchDarkly client initialization" } + elsif !@data_source.initialized? + @config.logger.error { "[LDClient] LaunchDarkly client initialization failed" } end end