docs: document the working Oxygen deploy OOM fix (supersedes #444) - #469
Conversation
Large storefronts hit `JavaScript heap out of memory` (exit 134) during the Oxygen deploy. The server sourcemap is ~4.6MB, about two thirds of the server output, and generating it is a major memory driver. Documents `SHOPIFY_HYDROGEN_FLAG_SOURCEMAP=false` on the deploy step, alongside the existing `NODE_OPTIONS` heap bump. Measured on this repo: default build: dist/server 6.9M, 1 .map, peak RSS 1362MB SHOPIFY_HYDROGEN_FLAG_SOURCEMAP=false: dist/server 2.3M, 0 .map, peak RSS 1136MB Setting `build.sourcemap: false` in vite.config.ts does NOT work: the Shopify CLI passes `sourcemap` inline to Vite, and inline config overrides the config file. Verified by building both ways, the server sourcemap was byte-identical (4,833,304 bytes) with and without it. Supersedes #444.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a1d6e4835
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| > run: npx shopify hydrogen deploy | ||
| > env: | ||
| > SHOPIFY_HYDROGEN_DEPLOYMENT_TOKEN: ${{ secrets.OXYGEN_DEPLOYMENT_TOKEN_... }} | ||
| > SHOPIFY_HYDROGEN_FLAG_SOURCEMAP: "false" |
There was a problem hiding this comment.
Use a deploy path that honors the sourcemap flag
In the generated Oxygen workflow where this step runs npx shopify hydrogen deploy, setting this env var does not affect the bundled @shopify/cli 4.5.2 deploy build: the command manifest registers SHOPIFY_HYDROGEN_FLAG_SOURCEMAP for hydrogen:build, but hydrogen:deploy has no sourcemap flag (node_modules/@shopify/cli/oclif.manifest.json:5854-5857, :6206), and deploy's internal build function still calls Je(..., sourcemap: !0, ...) (node_modules/@shopify/cli/dist/chunk-AATUQ2AY.js:132). Users following this README will still generate the server map and can still hit the Oxygen OOM, so the documented workaround needs to use a custom build/deploy path or a deploy option that is actually honored.
Useful? React with 👍 / 👎.
Why
A client storefront hit
FATAL ERROR: JavaScript heap out of memory(exit 134) during the Oxygen deploy. The build died before uploading completely, so the environment served HTML referencing client JS that was never published and the storefront rendered blank (alloxygen-v2/.../assets/*.jsreturned 404).Supersedes #444, which tried to fix this with
build.sourcemap: falseinvite.config.ts. That does not work.Why the config change doesn't work
Two independent reasons, either one fatal:
1. It was already
false. Asking Vite to resolve the config on unmodifiedmainreturnsfalsefor both the client and SSR passes. That's the default. #444 set a value to what it already was.2. The Shopify CLI overrides the config file. The server build receives
sourcemapinline, and deploy hardcodes it totrue:Inline config beats the config file in Vite, so the theme repo cannot turn this off from
vite.config.ts.Verified by building both ways:
What actually works
The CLI owns the flag, so use the CLI's switch. Measured on this repo:
.mapfilesSHOPIFY_HYDROGEN_FLAG_SOURCEMAP=falseServer bundle drops by 4.6 MB, peak memory by ~226 MB (17%).
npx shopify hydrogen build --no-sourcemapproduces the same result; the env var is documented because it drops straight into the generated workflow next toNODE_OPTIONS.Changes
README only. Documents
SHOPIFY_HYDROGEN_FLAG_SOURCEMAP=falseon the deploy step alongside the existingNODE_OPTIONSheap bump, and records whyvite.config.tscan't solve it so the next person debugging an OOM doesn't retry the dead end.No
vite.config.tschange. No runtime behavior change.Verification
npm run biome— 324 files, 0 warnings.mapfiles, server 2.3 MB