Class: ReactOnRailsPro::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/react_on_rails_pro/engine.rb

Class Method Summary collapse

Class Method Details

.log_license_statusObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/react_on_rails_pro/engine.rb', line 30

def log_license_status
  status = ReactOnRailsPro::LicenseValidator.license_status

  case status
  when :valid
    log_legacy_file_cleanup_notice if legacy_license_file_present?
    log_valid_license
  when :missing
    log_legacy_license_migration_notice if legacy_license_file_present?
    log_license_issue("No license found", "Get a license at #{LICENSE_URL}")
  when :expired
    expiration = ReactOnRailsPro::LicenseValidator.license_expiration
    expired_on = expiration ? " (expired on #{expiration.strftime('%Y-%m-%d')})" : ""
    log_license_issue("License has expired#{expired_on}", "Renew your license at #{LICENSE_URL}")
  when :invalid
    log_license_issue("Invalid license", "Get a license at #{LICENSE_URL}")
  end
end

.log_rsc_streaming_middleware_warningObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/react_on_rails_pro/engine.rb', line 49

def log_rsc_streaming_middleware_warning
  return unless ReactOnRailsPro.configuration.enable_rsc_support
  return if Rails.env.test?

  middleware_names = middleware_stack_names
  problematic = RSC_STREAMING_MIDDLEWARE_WARNING_TARGETS & middleware_names
  return if problematic.empty?

  route_path = ReactOnRailsPro.configuration.rsc_payload_generation_url_path
  Rails.logger.warn(
    "[React on Rails Pro] React Server Components support is enabled and the middleware " \
    "stack includes #{problematic.join(', ')}. Compression and other response-transforming " \
    "middleware can interfere with ActionController::Live NDJSON streaming. If your " \
    "`#{route_path}` payload route is not already exempt, consider bypassing " \
    "#{problematic.join(', ')} for that endpoint if you see stalled or corrupted RSC payloads."
  )
end