Class: ReactOnRailsPro::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/react_on_rails_pro/configuration.rb,
sig/react_on_rails_pro/configuration.rbs

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

DEFAULT_RENDERER_URL =

Returns:

  • (String)
"http://localhost:3800"
DEFAULT_RENDERER_METHOD =

Returns:

  • (String)
"ExecJS"
DEFAULT_RENDERER_FALLBACK_EXEC_JS =

Returns:

  • (Boolean)
true
DEFAULT_RENDERER_HTTP_POOL_SIZE =

Maximum concurrent HTTP/2 streams per persistent client. When Fiber.scheduler is available, clients are reused across requests within the same scheduler, making this limit effective. Without a scheduler, clients are per-request and this limits streams on that single request.

Returns:

  • (Integer)
10
DEFAULT_RENDERER_HTTP_POOL_TIMEOUT =

TCP connect timeout. Request and response processing are still bounded by ssr_timeout.

Returns:

  • (Integer)
5
DEFAULT_RENDERER_HTTP_POOL_WARN_TIMEOUT =

Returns:

  • (Float)
0.25
DEFAULT_RENDERER_HTTP_KEEP_ALIVE_TIMEOUT =

Returns:

  • (Integer)
30
DEFAULT_SSR_TIMEOUT =

Returns:

  • (Integer)
5
DEFAULT_PRERENDER_CACHING =

Returns:

  • (Boolean)
false
DEFAULT_TRACING =

Returns:

  • (Boolean)
false
DEFAULT_DEPENDENCY_GLOBS =

Returns:

  • (Array[String])
[].freeze
DEFAULT_EXCLUDED_DEPENDENCY_GLOBS =

Returns:

  • (Array[String])
[].freeze
DEFAULT_REMOTE_BUNDLE_CACHE_ADAPTER =

Returns:

  • (nil)
nil
DEFAULT_ROLLING_DEPLOY_ADAPTER =

Returns:

  • (nil)
nil
DEFAULT_ROLLING_DEPLOY_TOKEN =

Returns:

  • (nil)
nil
DEFAULT_ROLLING_DEPLOY_PREVIOUS_URL =

Returns:

  • (nil)
nil
DEFAULT_ROLLING_DEPLOY_MOUNT_PATH =

Returns:

  • (String)
"/react_on_rails_pro/rolling_deploy"
ROLLING_DEPLOY_TOKEN_MIN_LENGTH =

Minimum bearer-token length when using the built-in HTTP rolling-deploy adapter. 32 chars matches SecureRandom.hex(16) and rules out obviously low-entropy values like "secret" or short app names without forcing a specific generator.

Returns:

  • (Integer)
32
DEFAULT_RENDERER_REQUEST_RETRY_LIMIT =

Returns:

  • (Integer)
5
DEFAULT_THROW_JS_ERRORS =

Returns:

  • (Boolean)
true
DEFAULT_RENDERING_RETURNS_PROMISES =

Returns:

  • (Boolean)
false
DEFAULT_PROFILE_SERVER_RENDERING_JS_CODE =

Returns:

  • (Boolean)
false
DEFAULT_RAISE_NON_SHELL_SERVER_RENDERING_ERRORS =

Returns:

  • (Boolean)
false
DEFAULT_ENABLE_RSC_SUPPORT =

Returns:

  • (Boolean)
false
DEFAULT_RSC_PAYLOAD_GENERATION_URL_PATH =

Returns:

  • (String)
"rsc_payload/"
DEFAULT_RSC_BUNDLE_JS_FILE =

Returns:

  • (String)
"rsc-bundle.js"
DEFAULT_REACT_CLIENT_MANIFEST_FILE =

Returns:

  • (String)
"react-client-manifest.json"
DEFAULT_REACT_SERVER_CLIENT_MANIFEST_FILE =

Returns:

  • (String)
"react-server-client-manifest.json"
DEFAULT_CONCURRENT_COMPONENT_STREAMING_BUFFER_SIZE =

Returns:

  • (Integer)
64
DEFAULT_CACHE_TAG_INDEX_EXPIRES_IN =

Ceiling TTL for a tag->cache-key index entry when the tagged cache entry has no :expires_in of its own (see ReactOnRailsPro::Cache::TagIndex).

Returns:

  • (Integer)
604_800
DEFAULT_CACHE_TAG_INDEX_MAX_KEYS =

Maximum cache-entry keys recorded per tag; the oldest keys are dropped (with a warning) beyond this, and drop out of tag revalidation.

Returns:

  • (Integer)
5_000
ROLLING_DEPLOY_UPLOAD_POSITIONAL_PARAMS =

Returns:

  • (Array[Symbol])
%i[req opt rest].freeze
ROLLING_DEPLOY_UPLOAD_KEYWORD_PARAMS =

Returns:

  • (Array[Symbol])
%i[key keyreq].freeze
ROLLING_DEPLOY_UPLOAD_ALL_KEYWORD_PARAMS =

Returns:

  • (Array[Symbol])
%i[keyrest].freeze
ROLLING_DEPLOY_UPLOAD_REQUIRED_KEYWORDS =

Returns:

  • (Array[Symbol])
%i[bundle assets].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(renderer_url: nil, renderer_password: nil, server_renderer: nil, renderer_use_fallback_exec_js: nil, prerender_caching: nil, renderer_http_pool_size: nil, renderer_http_pool_timeout: nil, renderer_http_pool_warn_timeout: nil, renderer_http_keep_alive_timeout: nil, tracing: nil, dependency_globs: nil, excluded_dependency_globs: nil, rendering_returns_promises: nil, remote_bundle_cache_adapter: nil, rolling_deploy_adapter: nil, rolling_deploy_token: nil, rolling_deploy_previous_url: nil, rolling_deploy_mount_path: nil, ssr_pre_hook_js: nil, assets_to_copy: nil, renderer_request_retry_limit: nil, throw_js_errors: nil, ssr_timeout: nil, profile_server_rendering_js_code: nil, raise_non_shell_server_rendering_errors: nil, enable_rsc_support: nil, rsc_payload_generation_url_path: nil, rsc_bundle_js_file: nil, react_client_manifest_file: nil, react_server_client_manifest_file: nil, concurrent_component_streaming_buffer_size: DEFAULT_CONCURRENT_COMPONENT_STREAMING_BUFFER_SIZE, cache_tag_index_expires_in: DEFAULT_CACHE_TAG_INDEX_EXPIRES_IN, cache_tag_index_max_keys: DEFAULT_CACHE_TAG_INDEX_MAX_KEYS) ⇒ Configuration

rubocop:disable Metrics/AbcSize



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/react_on_rails_pro/configuration.rb', line 197

def initialize(renderer_url: nil, renderer_password: nil, server_renderer: nil, # rubocop:disable Metrics/AbcSize
               renderer_use_fallback_exec_js: nil, prerender_caching: nil,
               renderer_http_pool_size: nil, renderer_http_pool_timeout: nil,
               renderer_http_pool_warn_timeout: nil, renderer_http_keep_alive_timeout: nil,
               tracing: nil,
               dependency_globs: nil, excluded_dependency_globs: nil, rendering_returns_promises: nil,
               remote_bundle_cache_adapter: nil, rolling_deploy_adapter: nil,
               rolling_deploy_token: nil, rolling_deploy_previous_url: nil,
               rolling_deploy_mount_path: nil,
               ssr_pre_hook_js: nil, assets_to_copy: nil,
               renderer_request_retry_limit: nil, throw_js_errors: nil, ssr_timeout: nil,
               profile_server_rendering_js_code: nil, raise_non_shell_server_rendering_errors: nil,
               enable_rsc_support: nil, rsc_payload_generation_url_path: nil,
               rsc_bundle_js_file: nil, react_client_manifest_file: nil,
               react_server_client_manifest_file: nil,
               concurrent_component_streaming_buffer_size: DEFAULT_CONCURRENT_COMPONENT_STREAMING_BUFFER_SIZE,
               cache_tag_index_expires_in: DEFAULT_CACHE_TAG_INDEX_EXPIRES_IN,
               cache_tag_index_max_keys: DEFAULT_CACHE_TAG_INDEX_MAX_KEYS)
  self.renderer_url = renderer_url
  self.renderer_password = renderer_password
  self.server_renderer = server_renderer
  self.renderer_use_fallback_exec_js = renderer_use_fallback_exec_js
  self.prerender_caching = prerender_caching
  assign_initial_renderer_http_pool_size(renderer_http_pool_size)
  self.renderer_http_pool_timeout = renderer_http_pool_timeout
  self.renderer_http_pool_warn_timeout = renderer_http_pool_warn_timeout
  # Initial assignment applies the default constructor value; warn only when users set this deprecated config.
  assign_initial_renderer_http_keep_alive_timeout(renderer_http_keep_alive_timeout)
  self.tracing = tracing
  self.rendering_returns_promises = server_renderer == "NodeRenderer" ? rendering_returns_promises : false
  self.dependency_globs = dependency_globs
  self.excluded_dependency_globs = excluded_dependency_globs
  self.remote_bundle_cache_adapter = remote_bundle_cache_adapter
  self.rolling_deploy_adapter = rolling_deploy_adapter
  self.rolling_deploy_token = rolling_deploy_token
  self.rolling_deploy_previous_url = rolling_deploy_previous_url
  # Constructor nil/blank means "use the default"; configure-block assignment
  # can still set nil/blank later to opt out of the engine auto-mount.
  self.rolling_deploy_mount_path = rolling_deploy_mount_path.presence || DEFAULT_ROLLING_DEPLOY_MOUNT_PATH
  self.ssr_pre_hook_js = ssr_pre_hook_js
  self.assets_to_copy = assets_to_copy
  self.renderer_request_retry_limit = renderer_request_retry_limit
  self.throw_js_errors = throw_js_errors
  self.ssr_timeout = ssr_timeout
  self.profile_server_rendering_js_code = profile_server_rendering_js_code
  self.raise_non_shell_server_rendering_errors = raise_non_shell_server_rendering_errors
  self.enable_rsc_support = enable_rsc_support
  self.rsc_payload_generation_url_path = rsc_payload_generation_url_path
  self.rsc_bundle_js_file = rsc_bundle_js_file
  self.react_client_manifest_file = react_client_manifest_file
  self.react_server_client_manifest_file = react_server_client_manifest_file
  self.concurrent_component_streaming_buffer_size = concurrent_component_streaming_buffer_size
  self.cache_tag_index_expires_in = cache_tag_index_expires_in
  self.cache_tag_index_max_keys = cache_tag_index_max_keys
end

Instance Attribute Details

#assets_to_copyArray[String]?

Returns the value of attribute assets_to_copy.

Returns:

  • (Array[String], nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def assets_to_copy
  @assets_to_copy
end

#cache_tag_index_expires_inNumeric, ActiveSupport::Duration

Returns the value of attribute cache_tag_index_expires_in.

Returns:



122
123
124
# File 'lib/react_on_rails_pro/configuration.rb', line 122

def cache_tag_index_expires_in
  @cache_tag_index_expires_in
end

#cache_tag_index_max_keysInteger

Returns the value of attribute cache_tag_index_max_keys.

Returns:

  • (Integer)


122
123
124
# File 'lib/react_on_rails_pro/configuration.rb', line 122

def cache_tag_index_max_keys
  @cache_tag_index_max_keys
end

#concurrent_component_streaming_buffer_sizeInteger

Returns the value of attribute concurrent_component_streaming_buffer_size.

Returns:

  • (Integer)


122
123
124
# File 'lib/react_on_rails_pro/configuration.rb', line 122

def concurrent_component_streaming_buffer_size
  @concurrent_component_streaming_buffer_size
end

#dependency_globsArray[String]?

Returns the value of attribute dependency_globs.

Returns:

  • (Array[String], nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def dependency_globs
  @dependency_globs
end

#enable_rsc_supportBoolean?

Returns the value of attribute enable_rsc_support.

Returns:

  • (Boolean, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def enable_rsc_support
  @enable_rsc_support
end

#excluded_dependency_globsArray[String]?

Returns the value of attribute excluded_dependency_globs.

Returns:

  • (Array[String], nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def excluded_dependency_globs
  @excluded_dependency_globs
end

#prerender_cachingBoolean?

Returns the value of attribute prerender_caching.

Returns:

  • (Boolean, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def prerender_caching
  @prerender_caching
end

#profile_server_rendering_js_codeBoolean?

Returns the value of attribute profile_server_rendering_js_code.

Returns:

  • (Boolean, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def profile_server_rendering_js_code
  @profile_server_rendering_js_code
end

#raise_non_shell_server_rendering_errorsBoolean?

Returns the value of attribute raise_non_shell_server_rendering_errors.

Returns:

  • (Boolean, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def raise_non_shell_server_rendering_errors
  @raise_non_shell_server_rendering_errors
end

#react_client_manifest_fileString?

Returns the value of attribute react_client_manifest_file.

Returns:

  • (String, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def react_client_manifest_file
  @react_client_manifest_file
end

#react_server_client_manifest_fileString?

Returns the value of attribute react_server_client_manifest_file.

Returns:

  • (String, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def react_server_client_manifest_file
  @react_server_client_manifest_file
end

#remote_bundle_cache_adapterModule?

Returns the value of attribute remote_bundle_cache_adapter.

Returns:

  • (Module, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def remote_bundle_cache_adapter
  @remote_bundle_cache_adapter
end

#renderer_http_keep_alive_timeoutNumeric?

Returns the value of attribute renderer_http_keep_alive_timeout.

Returns:

  • (Numeric, nil)


122
123
124
# File 'lib/react_on_rails_pro/configuration.rb', line 122

def renderer_http_keep_alive_timeout
  @renderer_http_keep_alive_timeout
end

#renderer_http_pool_sizeInteger?

Returns the value of attribute renderer_http_pool_size.

Returns:

  • (Integer, nil)


122
123
124
# File 'lib/react_on_rails_pro/configuration.rb', line 122

def renderer_http_pool_size
  @renderer_http_pool_size
end

#renderer_http_pool_timeoutInteger?

Returns the value of attribute renderer_http_pool_timeout.

Returns:

  • (Integer, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def renderer_http_pool_timeout
  @renderer_http_pool_timeout
end

#renderer_http_pool_warn_timeoutFloat?

Returns the value of attribute renderer_http_pool_warn_timeout.

Returns:

  • (Float, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def renderer_http_pool_warn_timeout
  @renderer_http_pool_warn_timeout
end

#renderer_passwordString?

Returns the value of attribute renderer_password.

Returns:

  • (String, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def renderer_password
  @renderer_password
end

#renderer_request_retry_limitInteger?

Returns the value of attribute renderer_request_retry_limit.

Returns:

  • (Integer, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def renderer_request_retry_limit
  @renderer_request_retry_limit
end

#renderer_urlString?

Returns the value of attribute renderer_url.

Returns:

  • (String, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def renderer_url
  @renderer_url
end

#renderer_use_fallback_exec_jsBoolean?

Returns the value of attribute renderer_use_fallback_exec_js.

Returns:

  • (Boolean, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def renderer_use_fallback_exec_js
  @renderer_use_fallback_exec_js
end

#rendering_returns_promisesBoolean?

Returns the value of attribute rendering_returns_promises.

Returns:

  • (Boolean, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def rendering_returns_promises
  @rendering_returns_promises
end

#rolling_deploy_adapterModule?

Returns the value of attribute rolling_deploy_adapter.

Returns:

  • (Module, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def rolling_deploy_adapter
  @rolling_deploy_adapter
end

#rolling_deploy_mount_pathString?

Returns the value of attribute rolling_deploy_mount_path.

Returns:

  • (String, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def rolling_deploy_mount_path
  @rolling_deploy_mount_path
end

#rolling_deploy_previous_urlString?

Returns the value of attribute rolling_deploy_previous_url.

Returns:

  • (String, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def rolling_deploy_previous_url
  @rolling_deploy_previous_url
end

#rolling_deploy_tokenString?

Returns the value of attribute rolling_deploy_token.

Returns:

  • (String, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def rolling_deploy_token
  @rolling_deploy_token
end

#rsc_bundle_js_fileString?

Returns the value of attribute rsc_bundle_js_file.

Returns:

  • (String, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def rsc_bundle_js_file
  @rsc_bundle_js_file
end

#rsc_payload_generation_url_pathString?

Returns the value of attribute rsc_payload_generation_url_path.

Returns:

  • (String, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def rsc_payload_generation_url_path
  @rsc_payload_generation_url_path
end

#server_rendererString?

Returns the value of attribute server_renderer.

Returns:

  • (String, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def server_renderer
  @server_renderer
end

#ssr_pre_hook_jsString?

Returns the value of attribute ssr_pre_hook_js.

Returns:

  • (String, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def ssr_pre_hook_js
  @ssr_pre_hook_js
end

#ssr_timeoutInteger?

Returns the value of attribute ssr_timeout.

Returns:

  • (Integer, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def ssr_timeout
  @ssr_timeout
end

#throw_js_errorsBoolean?

Returns the value of attribute throw_js_errors.

Returns:

  • (Boolean, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def throw_js_errors
  @throw_js_errors
end

#tracingBoolean?

Returns the value of attribute tracing.

Returns:

  • (Boolean, nil)


110
111
112
# File 'lib/react_on_rails_pro/configuration.rb', line 110

def tracing
  @tracing
end

Instance Method Details

#check_react_on_rails_support_for_rscvoid

This method returns an undefined value.



276
277
278
279
280
281
282
283
284
285
# File 'lib/react_on_rails_pro/configuration.rb', line 276

def check_react_on_rails_support_for_rsc
  return unless enable_rsc_support

  return if ReactOnRails::Utils.respond_to?(:rsc_support_enabled?)

  raise ReactOnRailsPro::Error, <<~MSG
    React Server Components (RSC) support requires react_on_rails version 15.0.0 or higher.
    Please upgrade your react_on_rails gem to enable this feature.
  MSG
end

#configure_default_url_if_not_providedvoid

This method returns an undefined value.



349
350
351
# File 'lib/react_on_rails_pro/configuration.rb', line 349

def configure_default_url_if_not_provided
  self.renderer_url = renderer_url.presence || DEFAULT_RENDERER_URL
end

#node_renderer?Boolean

Returns:

  • (Boolean)


315
316
317
# File 'lib/react_on_rails_pro/configuration.rb', line 315

def node_renderer?
  ReactOnRailsPro.configuration.server_renderer == "NodeRenderer"
end

#rolling_deploy_http_adapter?Boolean

True when the configured rolling_deploy_adapter is the built-in HTTP adapter (or a subclass). Used by the engine to decide whether to auto-mount the rolling-deploy bundles controller.

Returns:

  • (Boolean)


269
270
271
272
273
274
# File 'lib/react_on_rails_pro/configuration.rb', line 269

def rolling_deploy_http_adapter?
  adapter = rolling_deploy_adapter
  return false if adapter.nil?

  adapter.is_a?(Class) && adapter <= ReactOnRailsPro::RollingDeployAdapters::Http
end

#setup_assets_to_copyvoid

This method returns an undefined value.



345
346
347
# File 'lib/react_on_rails_pro/configuration.rb', line 345

def setup_assets_to_copy
  self.assets_to_copy = (Array(assets_to_copy) if assets_to_copy.present?)
end

#setup_config_valuesvoid

This method returns an undefined value.



253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/react_on_rails_pro/configuration.rb', line 253

def setup_config_values
  configure_default_url_if_not_provided
  validate_url
  validate_remote_bundle_cache_adapter
  validate_rolling_deploy_adapter
  validate_rolling_deploy_http_adapter_config
  setup_renderer_password
  validate_renderer_password_for_production
  setup_assets_to_copy
  setup_execjs_profiler_if_needed
  check_react_on_rails_support_for_rsc
end

#setup_execjs_profiler_if_neededvoid

This method returns an undefined value.



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/react_on_rails_pro/configuration.rb', line 287

def setup_execjs_profiler_if_needed
  return unless profile_server_rendering_js_code && server_renderer == "ExecJS"

  if ExecJS.runtime == ExecJS::Runtimes::Node
    ExecJS.runtime = ExecJS::ExternalRuntime.new(
      name: "Node.js (V8)",
      command: ["node --prof"],
      runner_path: "#{ExecJS.root}/support/node_runner.js",
      encoding: "UTF-8"
    )
  elsif ExecJS.runtime == ExecJS::Runtimes::V8
    ExecJS.runtime = ExecJS::ExternalRuntime.new(
      name: "V8",
      command: ["d8 --prof"],
      runner_path: "#{ExecJS.root}/support/v8_runner.js",
      encoding: "UTF-8"
    )
  else
    current_runtime = ExecJS.runtime.name
    message = <<~MSG
      You have set `profile_server_rendering_js_code` to true, but the current execjs runtime is #{current_runtime}.
      ExecJS profiler only supports Node.js (V8) or V8 runtimes.
      You can set the runtime by setting the `EXECJS_RUNTIME` environment variable to either `Node` or `V8`.
    MSG
    raise ReactOnRailsPro::Error, message
  end
end

#setup_renderer_passwordvoid

This method returns an undefined value.



509
510
511
512
513
514
515
516
517
518
# File 'lib/react_on_rails_pro/configuration.rb', line 509

def setup_renderer_password
  resolve_renderer_password
  # The password is sent to the Node Renderer in the request body, never via
  # the URL (the HTTP client connects to scheme://host:port and the renderer
  # authenticates on the body field). A password embedded in renderer_url is
  # purely a Rails-side config convenience — once resolved above, strip it
  # from the stored URL so the credential can never leak through any log line
  # or error message that interpolates renderer_url downstream.
  strip_renderer_url_userinfo
end

#validate_remote_bundle_cache_adaptervoid

This method returns an undefined value.



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/react_on_rails_pro/configuration.rb', line 364

def validate_remote_bundle_cache_adapter
  if !remote_bundle_cache_adapter.nil? && !remote_bundle_cache_adapter.is_a?(Module)
    raise ReactOnRailsPro::Error, "config.remote_bundle_cache_adapter can only have a module or class assigned"
  end

  return unless remote_bundle_cache_adapter.is_a?(Module)

  unless remote_bundle_cache_adapter.methods.include?(:build)
    raise ReactOnRailsPro::Error,
          "config.remote_bundle_cache_adapter must have a class method named 'build'"
  end

  unless remote_bundle_cache_adapter.methods.include?(:fetch)
    raise ReactOnRailsPro::Error,
          "config.remote_bundle_cache_adapter must have a class method named 'fetch'" \
          "which takes a single named String parameter 'zipped_bundles_filename'" \
          "and returns the zipped file as a string if fetch attempt is successful & nil if not"
  end

  unless remote_bundle_cache_adapter.methods.include?(:upload) # rubocop:disable Style/GuardClause
    raise ReactOnRailsPro::Error,
          "config.remote_bundle_cache_adapter must have a class method named 'upload'" \
          "which takes a single named Pathname parameter 'zipped_bundles_filepath' & returns nil"
  end
end

#validate_renderer_password_for_productionvoid

This method returns an undefined value.



550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/react_on_rails_pro/configuration.rb', line 550

def validate_renderer_password_for_production
  return unless node_renderer?

  runtime_envs = [ENV.fetch("RAILS_ENV", nil), ENV.fetch("NODE_ENV", nil)].compact_blank.map(&:downcase)
  allowed_envs = %w[development test].freeze
  # Fail closed when both envs are unset; the error below gives fresh dev shells
  # the explicit development-env command.
  is_production_like = !(runtime_envs.any? && runtime_envs.all? { |env| allowed_envs.include?(env) })

  if renderer_password.blank?
    return unless is_production_like

    raise ReactOnRailsPro::Error, <<~MSG
      RENDERER_PASSWORD must be set in production-like environments (staging, production, etc.)
      when using the NodeRenderer.

      In development and test environments, the renderer password is optional and no authentication
      is required. In all other environments, you must explicitly configure a password to secure
      communication between Rails and the Node Renderer.
      #{unset_renderer_env_guidance(runtime_envs)}
      To secure the renderer, set the RENDERER_PASSWORD environment variable:

        export RENDERER_PASSWORD="your-secure-password"

      Rails reads it automatically. If you prefer to make it explicit in your initializer:

        # config/initializers/react_on_rails_pro.rb
        ReactOnRailsPro.configure do |config|
          config.renderer_password = ENV.fetch("RENDERER_PASSWORD")
        end

      Set the same password for the Node Renderer via the RENDERER_PASSWORD environment variable.
      Rails resolves the password in this order:
        1) config.renderer_password (blank values fall through to the next step)
        2) Password embedded in config.renderer_url (for example, https://:password@host:3800)
        3) ENV["RENDERER_PASSWORD"]

      If Rails and the Node Renderer disagree about startup behavior, verify both RAILS_ENV and NODE_ENV.

      Environment matrix (both RAILS_ENV and NODE_ENV are checked):
        development/test — password optional when every set env is development or test
        (both unset)     — treated as production-like; RENDERER_PASSWORD required
        staging          — RENDERER_PASSWORD required
        production       — RENDERER_PASSWORD required
        (mixed envs)     — RENDERER_PASSWORD required (e.g. NODE_ENV=production + RAILS_ENV=development)
    MSG
  end

  warn_if_renderer_password_weak
end

#validate_urlvoid

This method returns an undefined value.



353
354
355
356
357
358
359
360
361
362
# File 'lib/react_on_rails_pro/configuration.rb', line 353

def validate_url
  URI(renderer_url)
rescue URI::InvalidURIError
  # Deliberately do NOT echo renderer_url or the URI error message: a
  # malformed renderer_url may embed credentials (https://:password@host),
  # and reproducing it here would leak the password into logs/error reporters.
  raise ReactOnRailsPro::Error,
        "ReactOnRailsPro.config.renderer_url is not a parseable URI. Verify the value " \
        "(it is not echoed here because it may contain credentials)."
end