Skip to content

LTRAC-1420: Fix OpenNext buildCommand failing on native Windows - #3159

Open
jorgemoya wants to merge 1 commit into
canaryfrom
jorgemoya/ltrac-1420-opennext-windows-buildcommand
Open

LTRAC-1420: Fix OpenNext buildCommand failing on native Windows#3159
jorgemoya wants to merge 1 commit into
canaryfrom
jorgemoya/ltrac-1420-opennext-windows-buildcommand

Conversation

@jorgemoya

Copy link
Copy Markdown
Contributor

Linear: LTRAC-1420

What/Why?

A closed-beta partner (Vortex IQ) hit a hard failure running catalyst deploy / catalyst build on native Windows during the OpenNext step, and had to move the build to WSL to proceed. Local pnpm dev worked — only the OpenNext/Native Hosting build path failed.

Root cause is a single line in the generated OpenNext config template (packages/catalyst/templates/open-next.config.ts):

buildCommand: 'node_modules/.bin/next build',

OpenNext executes this string via @opennextjs/aws's buildNextjsApp(), which calls cp.execSync(command, ...). execSync runs through the system shell/bin/sh on Unix but cmd.exe on Windows. Under cmd.exe that command fails two ways:

  • Forward slashes — cmd.exe treats / as a switch character and can't resolve node_modules/.bin/next as the command token.
  • No executable extension — on Windows the runnable shim is next.cmd/next.ps1; the extensionless .bin/next is a POSIX sh script cmd.exe can't execute.

This template is only used on the OpenNext/Cloudflare deploy path (copied into .bigcommerce/ by build.ts before the build), which is why next dev — routed through the package.json scripts and the pnpm/npm .cmd shims — works fine while the deploy build breaks.

The fix invokes Next through node on its published bin:

buildCommand: 'node ./node_modules/next/dist/bin/next build',

node resolves on PATH on every platform and node.exe accepts forward-slash paths, so this runs identically under sh and cmd.exe. It's exactly what the .cmd/sh shims exec internally, so behavior is unchanged — it still runs next build directly and deliberately skips the project's generate step (the reason buildCommand is hardcoded rather than deferring to the build script, which is npm run generate && next build).

Only the template changes; core/.bigcommerce/open-next.config.ts is a gitignored copy regenerated on every build.

Testing

  • Verified the execution mechanism: @opennextjs/aws@3.9.16/dist/build/buildNextApp.js runs config.buildCommand via cp.execSync(command, { stdio: 'inherit', cwd }) (shell → cmd.exe on Windows).
  • Confirmed next's bin is ./dist/bin/next and that the new command is equivalent to what the .bin shims exec.
  • On non-Windows, catalyst build / catalyst deploy continue to build via OpenNext unchanged.
  • Ideal follow-up: a maintainer with a native Windows box confirms catalyst deploy completes end-to-end without WSL.

Migration

None. Config is regenerated on each build; no consumer action required.

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
catalyst Ready Ready Preview Aug 6, 2026 7:08pm

Request Review

@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5e757e1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Report

Comparing against baseline from 27eec2f (2026-08-03).

No bundle size changes detected.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Unlighthouse Performance Comparison — Vercel

Comparing PR preview deployment Unlighthouse scores vs production Unlighthouse scores.

Summary Score

Aggregate score across all categories as reported by Unlighthouse.

Prod Desktop Prod Mobile Preview Desktop Preview Mobile
Score 90 92 92 94

Category Scores

Category Prod Desktop Prod Mobile Preview Desktop Preview Mobile
Performance 71 70 70 78
Accessibility 95 98 95 95
Best Practices 100 100 100 100
SEO 88 88 100 100

Core Web Vitals

Metric Prod Desktop Prod Mobile Preview Desktop Preview Mobile
LCP 5.4 s 5.8 s 5.8 s 6.0 s
CLS 0.037 0.184 0.039 0
FCP 1.2 s 1.2 s 1.2 s 1.2 s
TBT 0 ms 10 ms 0 ms 0 ms
Max Potential FID 50 ms 60 ms 30 ms 50 ms
Time to Interactive 5.4 s 5.8 s 5.8 s 6.0 s

Full Unlighthouse report →

…indows

The generated open-next.config.ts hardcoded 'node_modules/.bin/next build'
as its buildCommand. OpenNext runs this via execSync, which shells out to
cmd.exe on native Windows — where the extensionless POSIX shim and
forward-slash path both fail to resolve, breaking catalyst build/deploy.
Invoke 'node ./node_modules/next/dist/bin/next build' instead, which works
identically across sh and cmd.exe while still skipping the project's
generate step.

Refs LTRAC-1420

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jorgemoya
jorgemoya force-pushed the jorgemoya/ltrac-1420-opennext-windows-buildcommand branch from c6aa972 to 5e757e1 Compare August 6, 2026 19:07
@jorgemoya
jorgemoya marked this pull request as ready for review August 6, 2026 19:09
@jorgemoya
jorgemoya requested a review from a team as a code owner August 6, 2026 19:09
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