Pro licensing and observability
React on Rails Pro keeps paid features accountable through local license checks and makes renderer work visible through logs, error reports, and traces. It also protects streamed output and rolling-deploy artifact transfer with bounded work, safe payload handling, and fallback paths. This page complements the Pro rendering platform overview and connects with Node renderer processes, async props and streaming SSR, and renderer cache and rolling deploys.
License validation
License sources and status
The license validator checks a signed Pro license token before the application reports its license state. Rails and the Node renderer apply the same rules so both sides agree on whether a license is usable. The token can come from explicit application configuration or from REACT_ON_RAILS_PRO_LICENSE.
Signature checks use the bundled ShakaCode public key. Operators can refresh this key with the react_on_rails_pro:update_public_key task when the license service publishes a new key.
Validation checks the token signature and the allowed RS256 algorithm. It then checks the organization, plan, and expiration. The result is one of four states:
valid: the token passes all checks.expired: the token is well formed but past its expiration time.invalid: the token fails signature or claim checks.missing: no token is available.
The validator caches results for the life of the process. A newly configured explicit token uses a separate cache key, while changing the environment-based token still requires the normal process reset or restart. Product attribution remains required for every recognized plan and permitted free use.
References: react_on_rails_pro/…/license_validator.rb• L18-93 react_on_rails_pro/…/license_validator.rb• L108-153 react_on_rails_pro/…/license_validator.rb• L220-285 react_on_rails_pro/…/license_public_key.rb• L16-41 packages/…/licenseValidator.ts• L19-52 packages/…/licenseValidator.ts• L89-123 packages/…/licenseValidator.ts• L183-237
License status reporting
Rails reports the license state after application initialization without stopping the application. This keeps a missing or bad license visible in logs while leaving the application startup path available for diagnosis.
The react_on_rails_pro:verify_license task is the explicit check for deployment and operations. It supports human-readable text or JSON output. Its report includes license identity, expiration data, attribution status, and a renewal signal when the license is expired or has 30 days or less remaining. The task exits with failure when the status is anything other than valid.
References: react_on_rails_pro/…/engine.rb• L44-48 react_on_rails_pro/…/engine.rb• L70-114 react_on_rails_pro/…/license.rake• L18-33 react_on_rails_pro/…/license_task_formatter.rb• L21-41 react_on_rails_pro/…/license_task_formatter.rb• L43-83
OpenTelemetry instrumentation
Renderer request traces
OpenTelemetry is an optional trace system for following work between the Rails process and the Node renderer. When a provider is available, Rails creates a client span around renderer HTTP work and sends only supported trace headers to the renderer. The span records request method, a normalized path, request and response byte counts, and the response status.
The Rails request, async props work, and streamed response consumption preserve the active trace context. This lets one operation remain connected when work crosses async tasks or a streaming boundary. Dynamic bundle identifiers in paths are replaced with stable placeholders so traces group related requests instead of creating a new path value for every bundle.
References: react_on_rails_pro/…/open_telemetry.rb• L19-28 react_on_rails_pro/…/open_telemetry.rb• L30-127 react_on_rails_pro/…/open_telemetry.rb• L136-207 react_on_rails_pro/…/renderer_http_client.rb• L772-793 react_on_rails_pro/…/request.rb• L188-201 react_on_rails_pro/…/stream_request.rb• L138-147
Node tracing integration
The Node renderer can create its own OpenTelemetry provider or attach its SSR spans to a provider owned by the host application. It can add HTTP and Fastify instrumentation and can wrap the full SSR request plus named sub-operations such as VM execution and response preparation. Tracing is opt-in, so a renderer without the optional OpenTelemetry packages can still load and render.
The host owns provider setup and shutdown when existing-provider mode is used. In renderer-owned mode, initialization claims the global provider before module instrumentation is enabled. Failed setup disables partial instrumentation and cleans up the provider according to ownership. Shutdown has a bounded wait, so telemetry cannot hold a worker restart or application close indefinitely.
Resource attributes add deployment context to spans. The service name uses this order: OTEL_SERVICE_NAME, the explicit serviceName option, explicit or environment resource attributes, and then react-on-rails-pro-node-renderer. Resource detectors add lower-priority attributes. Detector failures are logged and omitted instead of stopping renderer setup.
Custom instrumentations are added after the built-in HTTP and Fastify groups when built-ins are enabled. An empty instrumentation list does not load the built-ins. Existing-provider mode uses the host SDK and warns when renderer-owned options are supplied; it also waits for a registered provider with a working context manager before it installs renderer spans.
The shared tracing layer is a pass-through when no integration is active. If a tracing adapter fails before it starts render work, rendering continues without a span. If it fails after work starts, the error is kept so the work is not run twice.
References: packages/…/opentelemetry.ts• L51-88 packages/…/opentelemetry.ts• L180-246 packages/…/opentelemetry.ts• L287-342 packages/…/opentelemetry.ts• L344-378 packages/…/opentelemetry.ts• L380-565 packages/…/opentelemetryConfig.ts• L85-175 packages/…/tracing.ts• L43-120 packages/…/tracing.ts• L182-254
Trace data limits
Trace attributes describe the operation rather than its executable request or response payload. The tracing contract permits safe metadata such as names, hashes, counts, and byte sizes. This limit matters because span attributes are not protected by the renderer's normal log redaction rules.
References: packages/…/opentelemetry.ts• L184-213 packages/…/tracing.ts• L143-150 react_on_rails_pro/…/open_telemetry.rb• L146-174
Error reporting
Rendering error flow
Rendering errors are returned to the caller as controlled renderer failures and are also sent to the configured error notifiers. The shared error reporter supports both error objects and text messages while protecting rendering from a notifier that itself fails.
For a normal render, a missing result, a returned error result, or an exception becomes an error response with no-cache headers. For a streamed render, errors can arrive after the response has started. The renderer reports those errors and keeps the original error stack when possible, including errors created in the sandboxed VM realm. The stream path avoids reporting the same error object more than once.
When RSC payloads are embedded into HTML, the client receives an error signal only when the server metadata says that errors exist or includes a non-blank error message or stack. Development and test payloads retain the diagnostic fields. Other environments receive only a generic error signal because full details are reported on the server.
References: packages/…/errorReporter.ts• L19-72 packages/…/utils.ts• L63-104 packages/…/handleRenderRequest.ts• L90-148 packages/…/vm.ts• L996-1034 packages/…/injectRSCPayload.ts• L88-123 packages/…/injectRSCPayload.ts• L2031-2087 react_on_rails_pro/…/rendering_error.rb• L16-18
Incremental stream errors
Incremental rendering treats the first request object as the point at which rendering starts. A malformed first object or a failure while starting its response stops the request. A malformed later update or a failure while applying that update is reported and skipped so later updates can still reach the renderer.
This split keeps an unusable initial request from producing a partial result while limiting the effect of one bad async update. The stream handler also reports failures from the response-start callback and preserves the final failure for its caller.
References: packages/…/handleIncrementalRenderStream.ts• L154-169 packages/…/handleIncrementalRenderStream.ts• L220-254 packages/…/handleIncrementalRenderStream.ts• L255-329
V8 log processing
Profile generation
V8 log processing turns renderer performance logs into JSON profiles that performance tools can inspect. The react_on_rails_pro:process_v8_logs task finds isolate-*.log files, moves them to the selected output directory, and runs the Node V8 profile processor for each file. The generated profiles can be opened in Speed Scope or Chrome Developer Tools.
The task deletes the moved source logs by default. Operators can keep them with keep_files=true. When more than 100 logs are present, the task asks for confirmation before it performs the batch operation. This protects an operator from an unexpected large or slow profile run.
References: react_on_rails_pro/…/v8_log_processor.rake• L18-32 react_on_rails_pro/…/v8_log_processor.rb• L16-27 react_on_rails_pro/…/v8_log_processor.rb• L29-61
Compression safeguards
Streaming middleware checks
Streaming SSR and RSC responses must remain lazy while they pass through Rack middleware. A middleware callback that calls body.each while deciding whether to compress the response consumes the stream and can deadlock an ActionController::Live response.
At Rails startup, the compression guard checks Rack::Deflater and Rack::Brotli callbacks. It probes custom :if callbacks with a streaming-shaped body and warns only when the callback iterates that body. The warning gives the callback location and the safe condition: bypass stream iteration unless the body responds to to_ary.
The probe has a short timeout and treats a callback that already iterated the body as a finding. If application-specific callback data prevents a probe, the guard logs a debug message and does not block startup. Normal compression remains compatible with streamed bodies; the guard targets only destructive custom checks.
References: react_on_rails_pro/…/engine.rb• L50-52 react_on_rails_pro/…/engine.rb• L92-98 react_on_rails_pro/…/compression_middleware_guard.rb• L19-58 react_on_rails_pro/…/compression_middleware_guard.rb• L62-105 react_on_rails_pro/…/compression_middleware_guard.rb• L107-175 react_on_rails_pro/…/streaming_compression_spec.rb• L22-29 react_on_rails_pro/…/streaming_compression_spec.rb• L70-80
RSC stylesheet fallback
The RSC HTML stream uses stylesheet hints when available and can infer more stylesheet links from the client chunk names in the streamed payload. The inference reads the module-local loadable-stats.json map and emits each stylesheet once with the rsc-css precedence marker. This gives streamed client components a path to load their styles before their reveal.
The stylesheet map is cached after a successful read. A missing file is an expected fallback and reports through the host diagnostic hook. Other read or parse failures remain visible through rate-limited warnings. Reads retry first after 100 milliseconds, then use an expanding delay up to 30 seconds. While the map is unavailable, the stream keeps its normal preload-tag fallback instead of failing the render.
The stream also holds incomplete HTML tags, raw-text elements, comments, foreign content, and split UTF-8 tails until it can safely process them. It defers a Suspense reveal briefly when stylesheet inference is still pending. This prevents the safeguard from inserting a link inside a partial HTML construct or splitting a character across output chunks.
References: packages/…/injectRSCPayload.ts• L126-205 packages/…/injectRSCPayload.ts• L230-357 packages/…/injectRSCPayload.ts• L1557-1617 packages/…/injectRSCPayload.ts• L1649-1672 packages/…/injectRSCPayload.ts• L1990-2109 packages/…/loadClientChunkStylesheetHrefs.test.ts• L87-196 packages/…/loadClientChunkStylesheetHrefs.test.ts• L198-371
Rolling-deploy artifact transfer
The built-in HTTP rolling-deploy adapter lets a new deployment fetch bundles and companion assets from a running Rails server. It uses authenticated HTTP, checks manifest provenance, and falls back across eligible origins so a failed seed does not fail the build; runtime retry remains available when seeding cannot complete.
The adapter accepts normalized HTTP or HTTPS origins and rejects credentials, queries, fragments, unsupported schemes, unsafe hash values, and ambiguous legacy artifact identities. Versioned artifact IDs are checked again against the downloaded bundle and assets before acceptance. HTTPS verifies the peer certificate. Plain HTTP warns when a bearer token would leave the local host in clear text; loopback URLs are quiet for local rehearsals.
Discovery and fetch use monotonic deadlines. Bundle responses stream into a temporary file rather than loading the full response into memory. The adapter rejects a compressed response over 50 MB before extraction and applies a separate uncompressed tarball limit. It also caps non-success response bodies while draining them, then removes temporary files on every failed path.
References: react_on_rails_pro/…/http.rb• L31-84 react_on_rails_pro/…/http.rb• L86-245 react_on_rails_pro/…/http.rb• L247-367 react_on_rails_pro/…/http.rb• L374-455 react_on_rails_pro/…/http.rb• L467-545 react_on_rails_pro/…/http_spec.rb• L27-164 react_on_rails_pro/…/http_spec.rb• L276-333 react_on_rails_pro/…/http_spec.rb• L336-489 react_on_rails_pro/…/http_spec.rb• L516-580
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the accepted license plans and license status rules aligned between the Rails validator and the Node validator.
- Keep license cache behavior aligned with the source used by deployment checks. A token source change can otherwise leave an old process result in place.
- Keep the bundled public key aligned with the key published by the license service when signing keys rotate. Refreshing the key must not leave Rails unable to verify current licenses.
- Keep trace header propagation, service-name precedence, resource-detector behavior, and path normalization consistent across the Rails client and the Node renderer.
- Keep renderer-owned OpenTelemetry cleanup within the worker shutdown limit. Host-owned provider mode must not shut down the host provider or apply renderer-owned SDK options.
- Keep span attributes limited to safe metadata. Do not derive them from the executable rendering request or response content.
- Keep the error metadata wire contract aligned between the renderer stream and
injectRSCPayload. Production clients need a generic signal while server-side reporting retains the full diagnostic. - Keep loadable-stats retry state and the host missing-file diagnostic contract aligned across the RSC package and Node renderer VM.
- Keep stylesheet inference and HTML-tail buffering compatible with the
rsc-cssprecedence marker and Suspense reveal order. - Keep rolling-deploy URL validation, artifact identity checks, compressed and uncompressed size caps, and temporary-file cleanup aligned with the bundle controller and tarball format.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A license token is missing, malformed, signed with another key, or expired | Startup logs a license issue and verify_license fails | Set the token through configuration or REACT_ON_RAILS_PRO_LICENSE, then run the verification task before deployment |
| The bundled public key is stale after a signing-key rotation | Current licenses fail signature checks | Refresh the key with react_on_rails_pro:update_public_key before verifying licenses |
| Rails and Node accept different plan or claim rules | One side can allow a Pro operation that the other side rejects | Keep the mirrored plan list and validation sequence synchronized |
| The host asks for existing-provider tracing before registering a provider or context manager | Renderer spans are not installed and the host receives a warning | Register the application SDK before calling renderer initialization |
| A resource detector throws or rejects an attribute | That detector's attributes are omitted | Review the warning and provide required service data through explicit configuration |
| Another OpenTelemetry provider owns the global provider | Renderer-managed tracing cannot safely install its integration | Use existing-provider mode and configure the provider in the host application |
| A tracing span receives request or response payload data | Sensitive content can reach the telemetry backend | Record names, hashes, counts, and byte sizes only |
A custom compression callback calls body.each on a streaming response | The response can be consumed early or deadlock | Remove the callback or guard it with a non-streaming to_ary check |
| The first incremental request object is invalid | The render request stops before a response can start | Send valid newline-delimited JSON for the initial object |
| A later incremental update is invalid or fails to apply | That update is skipped while the stream continues | Monitor error reports and fix the producer of the update data |
| loadable-stats.json is missing during a deploy race | CSS inference is skipped while the stream uses its fallback | Allow the retry window to recover or ship the stats file with the renderer bundle |
| A streamed HTML chunk ends inside a tag or raw-text region | A stylesheet link or reveal marker could be inserted into invalid HTML | Keep the incomplete tail until a safe boundary is available |
| A rolling-deploy origin uses plain HTTP outside loopback | The bearer token can be sent in clear text | Use HTTPS in production and treat the warning as a deployment defect |
| A rolling-deploy response exceeds the compressed cap or tarball size limit | Download or extraction stops and temporary files are removed | Keep response and tarball limits enabled and investigate the origin |
| A versioned artifact does not recompute to its requested identity | The origin's payload is rejected and another origin may be tried | Rebuild or republish the bundle and companion assets as one artifact |
| A batch contains more than 100 V8 logs | Profile processing can take longer than expected and move many files | Confirm the operation or stop it before processing begins |
Key files
| File | Why to read it |
|---|---|
| react_on_rails_pro/…/license_validator.rb | Defines the Rails-side license source, status model, claim checks, and cache boundary. |
| react_on_rails_pro/…/license_public_key.rb | Defines the public key used to verify signed Pro licenses and the key refresh path. |
| packages/…/licenseValidator.ts | Defines the matching Node-side license rules and process-level result cache. |
react_on_rails_pro/lib/tasks/license.rake | Shows the deployment-facing license verification contract and failure exit. |
| react_on_rails_pro/…/open_telemetry.rb | Shows how Rails renderer requests carry context and record HTTP measurements. |
| packages/…/opentelemetry.ts | Shows provider ownership, resource setup, instrumentation, SSR spans, rollback, and bounded shutdown. |
| packages/…/opentelemetryConfig.ts | Shows service-name precedence and resilient resource-detector handling. |
| packages/…/tracing.ts | Defines the renderer's integration-neutral tracing and sub-span contract. |
| packages/…/errorReporter.ts | Defines the boundary between renderer errors, logs, and external error notifiers. |
| packages/…/handleIncrementalRenderStream.ts | Shows which stream failures stop a request and which failures can be skipped. |
| packages/…/vm.ts | Shows how VM and stream rendering errors retain useful stacks for reporting. |
| packages/…/injectRSCPayload.ts | Shows client error redaction, embedded RSC diagnostics, stylesheet fallback, and safe stream boundaries. |
| react_on_rails_pro/…/v8_log_processor.rb | Shows the operational path from raw V8 logs to profile files. |
| react_on_rails_pro/…/compression_middleware_guard.rb | Shows how unsafe compression callbacks are detected without consuming a real stream. |
| react_on_rails_pro/…/http.rb | Shows authenticated artifact discovery, identity checks, bounded downloads, and cleanup. |
| react_on_rails_pro/…/tarball.rb | Defines the uncompressed artifact limit and extraction boundary used by the HTTP adapter. |