react-on-rails-pro-node-renderer 16.4.0 → 16.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-on-rails-pro-node-renderer",
3
- "version": "16.4.0",
3
+ "version": "16.5.0",
4
4
  "protocolVersion": "2.0.0",
5
5
  "description": "React on Rails Pro Node Renderer for server-side rendering",
6
6
  "main": "lib/ReactOnRailsProNodeRenderer.js",
@@ -60,7 +60,7 @@
60
60
  "sentry-testkit": "^5.0.6",
61
61
  "touch": "^3.1.0",
62
62
  "typescript": "^5.4.3",
63
- "react-on-rails": "16.4.0"
63
+ "react-on-rails": "16.5.0"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@honeybadger-io/js": ">=4.0.0",
@@ -95,7 +95,7 @@
95
95
  "bugs": {
96
96
  "url": "https://github.com/shakacode/react_on_rails/issues"
97
97
  },
98
- "homepage": "https://github.com/shakacode/react_on_rails/tree/master/packages/react-on-rails-pro-node-renderer#readme",
98
+ "homepage": "https://github.com/shakacode/react_on_rails/tree/main/packages/react-on-rails-pro-node-renderer#readme",
99
99
  "jest": {
100
100
  "clearMocks": true,
101
101
  "moduleNameMapper": {
@@ -6,6 +6,16 @@ const { version: fastifyVersion } = fastifyPackageJson;
6
6
  import log from './shared/log.js';
7
7
  import { majorVersion } from './shared/utils.js';
8
8
 
9
+ export function parseWorkersCount(value: string | null | undefined): number | null {
10
+ if (value == null) return null;
11
+ const normalized = value.trim();
12
+ if (normalized === '') return null;
13
+ const parsed = Number(normalized);
14
+ if (Number.isInteger(parsed) && parsed >= 0) return parsed;
15
+ console.warn(`[react-on-rails] Ignoring invalid worker count "${value}". Expected a non-negative integer.`);
16
+ return null;
17
+ }
18
+
9
19
  export async function reactOnRailsProNodeRenderer(config: Partial<Config> = {}) {
10
20
  const fastify5Supported = majorVersion(process.versions.node) >= 20;
11
21
  const fastify5OrNewer = majorVersion(fastifyVersion) >= 5;
package/src/master.ts CHANGED
@@ -31,17 +31,13 @@ export default function masterRun(runningConfig?: Partial<Config>) {
31
31
  if (status === 'valid') {
32
32
  log.info('[React on Rails Pro] License validated successfully.');
33
33
  } else if (status === 'missing') {
34
- logLicenseIssue(
35
- '[React on Rails Pro] No license found. Get a license at https://www.shakacode.com/react-on-rails-pro/',
36
- );
34
+ logLicenseIssue('[React on Rails Pro] No license found. Get a license at https://pro.reactonrails.com/');
37
35
  } else if (status === 'expired') {
38
36
  logLicenseIssue(
39
- '[React on Rails Pro] License has expired. Renew your license at https://www.shakacode.com/react-on-rails-pro/',
37
+ '[React on Rails Pro] License has expired. Renew your license at https://pro.reactonrails.com/',
40
38
  );
41
39
  } else {
42
- logLicenseIssue(
43
- '[React on Rails Pro] Invalid license. Get a license at https://www.shakacode.com/react-on-rails-pro/',
44
- );
40
+ logLicenseIssue('[React on Rails Pro] Invalid license. Get a license at https://pro.reactonrails.com/');
45
41
  }
46
42
 
47
43
  // Store config in app state. From now it can be loaded by any module using getConfig():
@@ -70,13 +70,13 @@ export interface Config {
70
70
  gracefulWorkerRestartTimeout: number | undefined;
71
71
  // If the rendering request is longer than this, it will be truncated in exception and logging messages
72
72
  maxDebugSnippetLength: number;
73
- // @deprecated See https://www.shakacode.com/react-on-rails-pro/docs/node-renderer/error-reporting-and-tracing.
73
+ // @deprecated See https://reactonrails.com/docs/building-features/node-renderer/error-reporting-and-tracing.
74
74
  honeybadgerApiKey?: string | null;
75
- // @deprecated See https://www.shakacode.com/react-on-rails-pro/docs/node-renderer/error-reporting-and-tracing.
75
+ // @deprecated See https://reactonrails.com/docs/building-features/node-renderer/error-reporting-and-tracing.
76
76
  sentryDsn?: string | null;
77
- // @deprecated See https://www.shakacode.com/react-on-rails-pro/docs/node-renderer/error-reporting-and-tracing.
77
+ // @deprecated See https://reactonrails.com/docs/building-features/node-renderer/error-reporting-and-tracing.
78
78
  sentryTracing?: boolean;
79
- // @deprecated See https://www.shakacode.com/react-on-rails-pro/docs/node-renderer/error-reporting-and-tracing.
79
+ // @deprecated See https://reactonrails.com/docs/building-features/node-renderer/error-reporting-and-tracing.
80
80
  sentryTracesSampleRate?: string | number;
81
81
  // If true, `{set/clear}{Timeout/Interval/Immediate}` and `queueMicrotask` are stubbed out to do nothing.
82
82
  stubTimers: boolean;
@@ -305,7 +305,7 @@ export function buildConfig(providedUserConfig?: Partial<Config>): Config {
305
305
  ) {
306
306
  log.error(
307
307
  'honeybadgerApiKey, sentryDsn, sentryTracing, and sentryTracesSampleRate are not used since RoRP 4.0. ' +
308
- 'See https://www.shakacode.com/react-on-rails-pro/docs/node-renderer/error-reporting-and-tracing.',
308
+ 'See https://reactonrails.com/docs/building-features/node-renderer/error-reporting-and-tracing.',
309
309
  );
310
310
  process.exit(1);
311
311
  }
@@ -0,0 +1,31 @@
1
+ import { parseWorkersCount } from '../src/ReactOnRailsProNodeRenderer';
2
+
3
+ describe('parseWorkersCount', () => {
4
+ afterEach(() => {
5
+ jest.restoreAllMocks();
6
+ });
7
+
8
+ it('returns null for missing and blank values', () => {
9
+ expect(parseWorkersCount(undefined)).toBeNull();
10
+ expect(parseWorkersCount(null)).toBeNull();
11
+ expect(parseWorkersCount('')).toBeNull();
12
+ expect(parseWorkersCount(' ')).toBeNull();
13
+ });
14
+
15
+ it('parses non-negative integers', () => {
16
+ expect(parseWorkersCount('0')).toBe(0);
17
+ expect(parseWorkersCount('3')).toBe(3);
18
+ expect(parseWorkersCount(' 4 ')).toBe(4);
19
+ });
20
+
21
+ it('warns and returns null for invalid values', () => {
22
+ const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => undefined);
23
+
24
+ expect(parseWorkersCount('workers')).toBeNull();
25
+ expect(parseWorkersCount('3.5')).toBeNull();
26
+ expect(parseWorkersCount('-1')).toBeNull();
27
+
28
+ expect(warnSpy).toHaveBeenCalledTimes(3);
29
+ expect(warnSpy.mock.calls[0][0]).toContain('Ignoring invalid worker count');
30
+ });
31
+ });