Skip to content

Commit

Permalink
fix: Log warning if client init timeout is considered high (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 committed May 10, 2024
1 parent 629ecb5 commit 61f4c7e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/ldclient-rb/ldclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 61f4c7e

Please sign in to comment.