Skip to content

fix(dev): version-safe Next dev launcher — quick-start on all supported Node - #72

Merged
ryandmonk merged 1 commit into
mainfrom
fix/dev-node-options
Aug 10, 2026
Merged

fix(dev): version-safe Next dev launcher — quick-start on all supported Node#72
ryandmonk merged 1 commit into
mainfrom
fix/dev-node-options

Conversation

@ryandmonk

Copy link
Copy Markdown
Contributor

The documented quick-start (pnpm --filter composer dev) failed with exit 9 on Node 22.0–22.3: the dev scripts inlined NODE_OPTIONS=--localstorage-file, a flag that only exists from Node 22.4 — while engines allows >=22. Reproduced on a real v22.0.0 binary; boundary bracketed at v22.4.0. The flag is load-bearing on Node ≥ 25 (stub server-side localStorage crashes Next dev SSR without it), so instead of removing it, each app's dev now runs through scripts/next-dev.mjs, which probes process.allowedNodeEnvironmentFlags and applies the flag only where this Node supports it — the hazard and the flag ship together.

Verified: Node 22.0.0 boots composer dev to HTTP 200 via the launcher (old form exits 9); clean-worktree pnpm install + documented command → 200 on v25 with the protection branch engaged; agent independent on :8787; web twin on :3000. 5-test regression guard (fail-first proven) forbids re-inlining the flag. Composer units 24/24; CONTRIBUTING updated; README unchanged (the command it documents now simply works).

🤖 Generated with Claude Code

… new Node

`pnpm --filter composer dev` (and `pnpm dev` for the studio) died with exit 9
on Node 22.0–22.3: the scripts inlined NODE_OPTIONS=--localstorage-file,
which only EXISTS from Node 22.4 — older allowed-by-engines Nodes reject it
("not allowed in NODE_OPTIONS") before Next starts. Reproduced byte-for-byte
on a real v22.0.0 binary. The prior clean-checkout verification missed it
because "clean" covered files, not the machine's Node (v25, where the flag
is valid).

The flag is load-bearing where it exists — Node ≥ 25's stub server-side
localStorage global crashes Next dev SSR without it (CONTRIBUTING said
"don't remove it") — so the fix keeps the protection and removes the bomb:
each app's dev now goes through scripts/next-dev.mjs, which probes
process.allowedNodeEnvironmentFlags and adds --localstorage-file only where
this Node permits it. The hazard and the flag ship together, so every
supported Node gets exactly what it needs.

Verified:
- Node 22.0.0 (real binary): old inline form exits 9; via the launcher,
  composer dev boots to HTTP 200.
- Node 22.4.0: flag allowed (boundary bracketed empirically).
- Node 25.2.1, CLEAN worktree: `pnpm install` + the documented
  `pnpm --filter composer dev` → HTTP 200, with the SSR-protection branch
  engaged; agent boots independently on :8787; web twin boots on :3000.
- Regression guard (5 unit tests, fail-first proven: the no-inline-flag
  assertion fails on the old package.json): no package script may hardcode
  the flag; env builder branches correctly on old/new Node and preserves
  caller NODE_OPTIONS. Composer units 24/24.

CONTRIBUTING troubleshooting updated to point at the launcher. README needs
no change — the documented command now works on everything engines allows.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 10, 2026 17:39
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 10, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
dspack-studio-composer 3f315f6 Aug 10 2026, 05:41 PM

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the documented dev quick-start failing on Node 22.0–22.3 by routing Next dev through a version-/flag-aware launcher that only applies --localstorage-file when the running Node allows it, preserving the SSR protection needed on Node ≥ 25 while keeping Node ≥ 22 compatible.

Changes:

  • Replace inlined NODE_OPTIONS=--localstorage-file=... in app dev scripts with a scripts/next-dev.mjs launcher that probes process.allowedNodeEnvironmentFlags.
  • Add a Vitest regression suite to prevent re-inlining the flag in package scripts and validate launcher env behavior.
  • Update CONTRIBUTING troubleshooting guidance to document the launcher and the Node 22.4 boundary.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
CONTRIBUTING.md Documents the new launcher behavior and why inlining the flag breaks Node < 22.4.
apps/web/scripts/next-dev.mjs New web Next dev launcher that conditionally injects --localstorage-file via NODE_OPTIONS.
apps/web/package.json Switches dev to invoke the new launcher instead of inlining NODE_OPTIONS.
apps/composer/scripts/next-dev.mjs New composer Next dev launcher mirroring the web launcher behavior.
apps/composer/scripts/next-dev.test.mjs Adds regression tests preventing re-inlining and validating conditional env injection.
apps/composer/package.json Switches dev to invoke the new launcher instead of inlining NODE_OPTIONS.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

return { ...baseEnv, NODE_OPTIONS: prior ? `${prior} ${flag}` : flag };
}

const invokedDirectly = process.argv[1] && import.meta.url.endsWith(process.argv[1].split("/").at(-1));
return { ...baseEnv, NODE_OPTIONS: prior ? `${prior} ${flag}` : flag };
}

const invokedDirectly = process.argv[1] && import.meta.url.endsWith(process.argv[1].split("/").at(-1));
import { describe, expect, it } from "vitest";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { webstorageEnv } from "./next-dev.mjs";
Comment on lines +29 to +32
it("new Node (flag allowed): the SSR protection is applied", () => {
const env = webstorageEnv({}, new Set(["--localstorage-file"]));
expect(env.NODE_OPTIONS).toBe("--localstorage-file=/tmp/dspack-composer-dev-localstorage");
});
@ryandmonk
ryandmonk merged commit 08b2f46 into main Aug 10, 2026
3 checks passed
@ryandmonk
ryandmonk deleted the fix/dev-node-options branch August 10, 2026 17:46
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.

2 participants