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 renderer connections per persistent client. With HTTP/1.1, each connection serves one request at a time, so this is also the request-concurrency cap for a client shared by a long-lived scheduler. Without a Fiber.scheduler, streaming renders use an ephemeral client and non-streaming renders use a persistent per-thread client; this bounds connections within each of those clients.

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_RENDERER_HTTP_FORCE_HTTP2 =

Returns:

  • (Boolean)
true
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_URLS =

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"
RSC_PAYLOAD_AUTHORIZER_POSITIONAL_PARAMS =
%i[req opt].freeze
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, license_token: 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, renderer_http_force_http2: DEFAULT_RENDERER_HTTP_FORCE_HTTP2, 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_urls: 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_payload_authorizer: 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



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/react_on_rails_pro/configuration.rb', line 233

def initialize(renderer_url: nil, renderer_password: nil, license_token: nil, # rubocop:disable Metrics/AbcSize
               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,
               renderer_http_force_http2: DEFAULT_RENDERER_HTTP_FORCE_HTTP2,
               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_urls: 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_payload_authorizer: 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.license_token = license_token
  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.renderer_http_force_http2 = renderer_http_force_http2
  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_urls = rolling_deploy_previous_urls
  # 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_payload_authorizer = rsc_payload_authorizer
  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)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

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:



128
129
130
# File 'lib/react_on_rails_pro/configuration.rb', line 128

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)


128
129
130
# File 'lib/react_on_rails_pro/configuration.rb', line 128

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)


128
129
130
# File 'lib/react_on_rails_pro/configuration.rb', line 128

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)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def dependency_globs
  @dependency_globs
end

#enable_rsc_supportBoolean?

Returns the value of attribute enable_rsc_support.

Returns:

  • (Boolean, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def enable_rsc_support
  @enable_rsc_support
end

#excluded_dependency_globsArray[String]?

Returns the value of attribute excluded_dependency_globs.

Returns:

  • (Array[String], nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def excluded_dependency_globs
  @excluded_dependency_globs
end

#license_tokenString?

Returns the value of attribute license_token.

Returns:

  • (String, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def license_token
  @license_token
end

#prerender_cachingBoolean?

Returns the value of attribute prerender_caching.

Returns:

  • (Boolean, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def prerender_caching
  @prerender_caching
end

#profile_server_rendering_js_codeBoolean?

Returns the value of attribute profile_server_rendering_js_code.

Returns:

  • (Boolean, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

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)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

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)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

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)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

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)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def remote_bundle_cache_adapter
  @remote_bundle_cache_adapter
end

#renderer_http_force_http2Boolean

Returns the value of attribute renderer_http_force_http2.

Returns:

  • (Boolean)


128
129
130
# File 'lib/react_on_rails_pro/configuration.rb', line 128

def renderer_http_force_http2
  @renderer_http_force_http2
end

#renderer_http_keep_alive_timeoutNumeric?

Returns the value of attribute renderer_http_keep_alive_timeout.

Returns:

  • (Numeric, nil)


128
129
130
# File 'lib/react_on_rails_pro/configuration.rb', line 128

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)


128
129
130
# File 'lib/react_on_rails_pro/configuration.rb', line 128

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)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

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)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def renderer_http_pool_warn_timeout
  @renderer_http_pool_warn_timeout
end

#renderer_passwordString?

Returns the value of attribute renderer_password.

Returns:

  • (String, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def renderer_password
  @renderer_password
end

#renderer_request_retry_limitInteger?

Returns the value of attribute renderer_request_retry_limit.

Returns:

  • (Integer, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def renderer_request_retry_limit
  @renderer_request_retry_limit
end

#renderer_urlString?

Returns the value of attribute renderer_url.

Returns:

  • (String, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def renderer_url
  @renderer_url
end

#renderer_use_fallback_exec_jsBoolean?

Returns the value of attribute renderer_use_fallback_exec_js.

Returns:

  • (Boolean, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

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)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def rendering_returns_promises
  @rendering_returns_promises
end

#rolling_deploy_adapterModule?

Returns the value of attribute rolling_deploy_adapter.

Returns:

  • (Module, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def rolling_deploy_adapter
  @rolling_deploy_adapter
end

#rolling_deploy_mount_pathString?

Returns the value of attribute rolling_deploy_mount_path.

Returns:

  • (String, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def rolling_deploy_mount_path
  @rolling_deploy_mount_path
end

#rolling_deploy_previous_urlsString, ...

Returns the value of attribute rolling_deploy_previous_urls.

Returns:

  • (String, Array[String], nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def rolling_deploy_previous_urls
  @rolling_deploy_previous_urls
end

#rolling_deploy_tokenString?

Returns the value of attribute rolling_deploy_token.

Returns:

  • (String, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def rolling_deploy_token
  @rolling_deploy_token
end

#rsc_bundle_js_fileString?

Returns the value of attribute rsc_bundle_js_file.

Returns:

  • (String, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def rsc_bundle_js_file
  @rsc_bundle_js_file
end

#rsc_payload_authorizerObject

Returns the value of attribute rsc_payload_authorizer.

Returns:

  • (Object)


128
129
130
# File 'lib/react_on_rails_pro/configuration.rb', line 128

def rsc_payload_authorizer
  @rsc_payload_authorizer
end

#rsc_payload_generation_url_pathString?

Returns the value of attribute rsc_payload_generation_url_path.

Returns:

  • (String, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def rsc_payload_generation_url_path
  @rsc_payload_generation_url_path
end

#server_rendererString?

Returns the value of attribute server_renderer.

Returns:

  • (String, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def server_renderer
  @server_renderer
end

#ssr_pre_hook_jsString?

Returns the value of attribute ssr_pre_hook_js.

Returns:

  • (String, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def ssr_pre_hook_js
  @ssr_pre_hook_js
end

#ssr_timeoutInteger?

Returns the value of attribute ssr_timeout.

Returns:

  • (Integer, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def ssr_timeout
  @ssr_timeout
end

#throw_js_errorsBoolean?

Returns the value of attribute throw_js_errors.

Returns:

  • (Boolean, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def throw_js_errors
  @throw_js_errors
end

#tracingBoolean?

Returns the value of attribute tracing.

Returns:

  • (Boolean, nil)


116
117
118
# File 'lib/react_on_rails_pro/configuration.rb', line 116

def tracing
  @tracing
end

Instance Method Details

#check_react_on_rails_support_for_rscvoid

This method returns an undefined value.



317
318
319
320
321
322
323
324
325
326
# File 'lib/react_on_rails_pro/configuration.rb', line 317

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.



417
418
419
# File 'lib/react_on_rails_pro/configuration.rb', line 417

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

#node_renderer?Boolean

Returns:

  • (Boolean)


356
357
358
# File 'lib/react_on_rails_pro/configuration.rb', line 356

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)


310
311
312
313
314
315
# File 'lib/react_on_rails_pro/configuration.rb', line 310

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.



413
414
415
# File 'lib/react_on_rails_pro/configuration.rb', line 413

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.



294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/react_on_rails_pro/configuration.rb', line 294

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.



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/react_on_rails_pro/configuration.rb', line 328

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.



577
578
579
580
581
582
583
584
585
586
# File 'lib/react_on_rails_pro/configuration.rb', line 577

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.



432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/react_on_rails_pro/configuration.rb', line 432

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.



618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
# File 'lib/react_on_rails_pro/configuration.rb', line 618

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.



421
422
423
424
425
426
427
428
429
430
# File 'lib/react_on_rails_pro/configuration.rb', line 421

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