From ccb0a881687c5e57085bc123a1196e282422f9be Mon Sep 17 00:00:00 2001 From: lux worker Date: Fri, 27 Nov 2026 12:10:26 +0000 Subject: [PATCH] fix(publish): build on the .nvmrc Node and stop a test aborting Node 22 The v1.14.0 publish run (45978491550) stalled in "Build and test" for 30+ minutes: the job used Node 22 while CI builds on .nvmrc (24). Cause: "bounds the callbacks a replay retains when each callback raises two more" drives logger feedback past the call stack. The SDK catches the RangeError in _logEvent and logs it with console.error. On Node 22 (22.22.1 to 22.23.5, reproduced on official builds), formatting that error with almost no stack left aborts the process with "FATAL ERROR: RegExpCompiler Allocation failed - process out of memory" inside util.inspect's stack-trace handling. A larger heap doesn't help. The Jest worker dies and the run waits for it. Node 24 is not affected. - The test now mocks console.error around the overflowing read (and checks only RangeErrors were logged), so context.test.js passes on Node 22 and 24. - publish.yml uses node-version-file: .nvmrc like build.yml, keeping registry-url and npm 11.6.2, and gives "Build and test" a 10-minute timeout. - check-release.test.js pins both. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/publish.yml | 4 +++- scripts/__tests__/check-release.test.js | 14 ++++++++++++++ src/__tests__/context.test.js | 10 +++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index de5463b..3b64c90 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,7 +24,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6 with: - node-version: '22' + node-version-file: '.nvmrc' registry-url: 'https://registry.npmjs.org' cache: npm @@ -38,7 +38,9 @@ jobs: id: release run: node scripts/check-release.js + # The build normally takes about a minute; a stalled test fails the run instead of blocking it. - name: Build and test + timeout-minutes: 10 run: npm run build - name: Inspect package diff --git a/scripts/__tests__/check-release.test.js b/scripts/__tests__/check-release.test.js index 160d553..2b94b1b 100644 --- a/scripts/__tests__/check-release.test.js +++ b/scripts/__tests__/check-release.test.js @@ -128,6 +128,20 @@ describe("publish workflow", () => { } }); + // Node 22 aborted context.test.js and left Jest waiting for 30+ minutes (v1.14.0, run 45978491550). + test("builds on the .nvmrc Node version, as CI does, and fails a stalled build in minutes", () => { + const setup = job.steps.find((step) => /actions\/setup-node@/.test(step.uses || "")); + expect(setup.with["node-version-file"]).toBe(".nvmrc"); + expect(setup.with["node-version"]).toBeUndefined(); + expect(setup.with["registry-url"]).toBe("https://registry.npmjs.org"); + const build = job.steps.find((step) => step.run === "npm run build"); + expect(build["timeout-minutes"]).toBeGreaterThan(0); + expect(build["timeout-minutes"]).toBeLessThanOrEqual(15); + const ci = yaml.load(readFileSync(path.join(__dirname, "../../.github/workflows/build.yml"), "utf8")); + const ciSetup = ci.jobs.build.steps.find((step) => /actions\/setup-node@/.test(step.uses || "")); + expect(ciSetup.with["node-version-file"]).toBe(setup.with["node-version-file"]); + }); + test("serializes all releases with one fixed package-wide lock without cancelling a running publish", () => { expect(Object.keys(workflow.jobs)).toEqual(["publish"]); expect(job.concurrency).toEqual({ diff --git a/src/__tests__/context.test.js b/src/__tests__/context.test.js index 9f96773..ebf252f 100644 --- a/src/__tests__/context.test.js +++ b/src/__tests__/context.test.js @@ -6919,7 +6919,15 @@ describe("Context", () => { }, }); context.attribute("user", user); - expect(context.variableValue("button.color", "D")).toBe("WINNER_AFTER_HOLDOUT"); + // The feedback recurses past the stack, and the SDK logs the caught RangeError there. A real + // console would format it with almost no stack left, which aborts the process on Node 22.23. + const consoleError = jest.spyOn(console, "error").mockImplementation(() => {}); + try { + expect(context.variableValue("button.color", "D")).toBe("WINNER_AFTER_HOLDOUT"); + expect(consoleError.mock.calls.every(([e]) => e instanceof RangeError)).toBe(true); + } finally { + consoleError.mockRestore(); + } // Without the callback budget each round doubles the held list until round 32. expect(errors).toBeGreaterThan(2048); expect(maxRetained).toBeLessThanOrEqual(1024);