$ the-wire · showcase
Hydrogen closes a cart-cache leak and two first-load races
By RepoJournal · Filed · About Shopify · Composed from the cited sources · methodology
Hydrogen shipped five fixes to its cart layer, the most consequential being a cache-header drop that could serve one shopper's cart to another, alongside two first-load ordering bugs and a storefront-script race.
fix(hydrogen): mark cart GET handler responses as personalized Shopify/hydrogen
`cartHandlers.get()` now marks its response private; before, a loader that destructured only `data` threw away the handler's cache headers, leaving the page or React Router `.data` response cacheable and letting a shared cache hand one user's cart to another.
fix(hydrogen): read the cart only on /cart, and keep changes made during the first load Shopify/hydrogen
Because that fix makes every cart read personalized, the template no longer reads the cart in the root loader and moves the server read to `/cart`, so other routes stay cacheable; the first-load bug it exposed, where a change built on an empty cart, is now fixed by waiting for the load to land.
fix(hydrogen): keep loaded discount codes when a code is applied during load (#4393) Shopify/hydrogen
`cartDiscountCodesUpdate` replaces the whole code list, and a request held until the first load landed was still sending the list built from an empty screen, dropping the loaded cart's codes. Held changes now rebase their payload onto the loaded cart before sending.
fix(hydrogen): configure Standard Actions after the deferred script runs Shopify/hydrogen
The cart store could configure Standard Actions after HTML parsing finished but before `standard-actions.js` ran, and the failure was silent and never retried, so direct `window.Shopify.actions.updateCart` calls fell through to Shopify's default handler instead of the endpoint set with `configureCartEndpoint()`.
fix(hydrogen): keep loaded discount codes when a code is applied during load Shopify/hydrogen
A stacked duplicate of the discount-code fix, and the CLI's World sync landed as routine mirror traffic: one file added, four changed, with the standing warning not to push to that branch.