Skip to content

test(backend): name the Node 25+ remedy where the failure happens - #1730

Merged
lilyshen0722 merged 1 commit into
mainfrom
fix/node-25-test-run-remedy
Sep 18, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
fix/node-25-test-run-remedy

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Small dev-experience fix, split out of the TASK-130 verification so that PR stays a behaviour change.

What happened

Verifying TASK-130 locally produced two dependency-shaped errors in a row, neither of which named a Node version:

  1. Module ts-jest in the transform option was not found — this checkout had no backend/node_modules.
  2. After npm ci: TypeError: Cannot read properties of undefined (reading 'prototype'), raised four frames under jws, inside buffer-equal-constant-time — a package the test never imports.

The whole story, including the exact Node-22 invocation, was already written in backend/TESTING.md. It was found after the detour, by a seat that had already written a SlowBuffer shim to get a run — because the failure points nowhere near the doc.

Changes

  • __tests__/utils/globalSetup.js — on Node ≥ 25, write the remedy to stderr before any worker fails. In globalSetup rather than setup.js so it prints once per run, not once per suite file (~40).
  • TESTING.md — state the measured boundary. buffer.SlowBuffer is a function on Node 22 and 24, undefined on 25 and 26; the section said "Node 26", i.e. the version it was first noticed on rather than the version the removal landed in. A Node 25 reader was being sent looking elsewhere.
  • AX audit entry 57 — the shape: a documented remedy that its own failure never points at.

Verification

  • npx -y -p node@25 … jest <suite> prints the warning, then proceeds.
  • npx -y -p node@22 … jest <suite> prints nothing, 28/28 pass.
  • The warning is advisory on purpose: a suite whose require graph reaches no jwt passes on 25+ regardless (the attention unit suite is one, which is how the boundary below was measured at all).

@samxu01
samxu01 force-pushed the fix/node-25-test-run-remedy branch from 6558f7e to a882660 Compare September 18, 2026 07:44

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate at a88266098a7769694ec1756a9b94d16acc608bdf: passes, nothing blocking. This is the first gate on #1730; it had no review before this.

Every claim is measured:

  • The boundary. npx -y -p node@N node -e "typeof require('buffer').SlowBuffer" gives function on v22.23.2 and v24.21.0 and undefined on v25.9.0 and v26.9.0. "Node 25+" is the exact range; the old "Node 26" understated it.
  • The pointer fires where the failure happens. globalSetup is wired (backend/jest.config.js:17). Running a suite at this head on Node 26.0.0 prints [globalSetup] Node 26.0.0 removed buffer.SlowBuffer … Run on Node 22 (what CI pins) before any worker loads. The same suite on Node 22 prints nothing, which is the control. Global setup runs before workers, so the pointer always precedes the failure it explains.
  • AX number 57 is free. Main's highest entry is 56 and no other open PR adds a ## 57.. (The stale #1213 and #1204 add 46 and 45, which already exist on main; that's their problem, not this PR's.)

One observation, not a defect. The pointer prints on every Node ≥ 25 run, including suites that never reach jsonwebtoken: approvalActionService.test.js passes 14/14 on Node 26 with the line printed. The wording is conditional ("any suite reaching jsonwebtoken will fail to load"), so it stays true. A reader whose run then passes shouldn't read it as an error.

@samxu01
samxu01 force-pushed the fix/node-25-test-run-remedy branch 5 times, most recently from a09a410 to 3d69be1 Compare September 18, 2026 11:04
Two dependency-shaped errors in a row, neither naming a Node version, led a
seat through: `Module ts-jest in the transform option was not found` (no
`backend/node_modules` in the checkout) → `npm ci` →
`TypeError: Cannot read properties of undefined (reading 'prototype')` raised
four frames under `jws`, inside a package the test never imports. The remedy
was already fully written in TESTING.md — findable only by a reader who
already suspected the version.

- `globalSetup` now writes the remedy to stderr on Node ≥ 25, once per run and
  before any worker fails. This is a per-run warning, not a per-suite one, so
  it prints once rather than on each of ~40 files.
- TESTING.md states the measured boundary: `buffer.SlowBuffer` is a `function`
  on 22 and 24, `undefined` on 25 and 26. The section said "Node 26", which is
  the version it was first noticed on, not the version the removal landed in —
  a Node 25 reader was sent looking elsewhere.
- AX audit entry 57 records the shape: a documented remedy that its own
  failure never points at.

Verified: warning prints under node@25 and is absent under node@22; the
attention suite still passes on both (its require graph reaches no jwt, which
is exactly why the warning is advisory rather than a hard failure).
@samxu01
samxu01 force-pushed the fix/node-25-test-run-remedy branch from 3d69be1 to b8ddece Compare September 18, 2026 11:31
@lilyshen0722
lilyshen0722 merged commit 23e0066 into main Sep 18, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant