Repository navigation
Closed
Labels
Description
What is the location of your example repository?
Which package or tool is having this issue?
Not sure if this is Hydrogen package or Oxygen deployment issue
What version of that package or tool are you using?
2025.1.2
What version of Remix are you using?
2.0.11
Steps to Reproduce
- Scaffold Shopify Hydrogen project using
npm create @shopify/hydrogen@latest - Install NPM package @shapediver/viewer.session
- Update
vite.config.tsoptimizeDeps to include @shapediver/viewer.session - Update
entry.server.tsxsecurity policy
connectSrc: [
'https://sdr8euc1.eu-central-1.shapediver.com'
]
- Run this code on products.$handle.tsx
const session = await createSession({
ticket:
'ba390f092896eaf776e6259f607aeb8946ac1359671be86608452f0718ef7311da4b9ba9d6eff6c841415ca7927ef211a018ba90591a32b75a2d578bd9e613dc1d00e9387ba90e69c809ac6f7f7f923cea54ea061dba656144fd788b65173466f3a8a20fd9429a-2511deeda86828ddaa2386dca43e3bea',
modelViewUrl: 'https://sdr8euc1.eu-central-1.shapediver.com',
});
This works locally
6. Deploy to Oxygen using npx shopify hydrogen deploy
Expected Behavior
Should deploy successfully and work the same way it works on localhost:3000
Actual Behavior
C:\Users\some-user\repos\shopfiy-shapediver-poc>npx shopify hydrogen deploy
? Select an environment to deploy to:
√ Preview (handle: preview)
Building project...
vite v5.4.14 building for production...
✓ 1483 modules transformed.
Generated an empty chunk: "sitemap._type._page_.xml_".
Generated an empty chunk: "account_.authorize".
Generated an empty chunk: "account_.logout".
Generated an empty chunk: "account._index".
Generated an empty chunk: "account_.login".
Generated an empty chunk: "discount._code".
Generated an empty chunk: "_sitemap.xml_".
Generated an empty chunk: "_robots.txt_".
Generated an empty chunk: "account._".
dist/client/oxygen.json 0.06 kB │ gzip: 0.07 kB
dist/client/assets/favicon-DZkC1E9c.svg 0.69 kB │ gzip: 0.35 kB
dist/client/.vite/manifest.json 12.62 kB │ gzip: 1.61 kB
dist/client/assets/reset-BKioPaen.css 1.23 kB │ gzip: 0.55 kB
dist/client/assets/app-CFDV3s0Q.css 5.60 kB │ gzip: 1.60 kB
dist/client/assets/sitemap._type._page_.xml_-l0sNRNKZ.js 0.00 kB │ gzip: 0.02 kB
dist/client/assets/account_.authorize-l0sNRNKZ.js 0.00 kB │ gzip: 0.02 kB
dist/client/assets/account_.logout-l0sNRNKZ.js 0.00 kB │ gzip: 0.02 kB
dist/client/assets/account._index-l0sNRNKZ.js 0.00 kB │ gzip: 0.02 kB
dist/client/assets/account_.login-l0sNRNKZ.js 0.00 kB │ gzip: 0.02 kB
dist/client/assets/discount._code-l0sNRNKZ.js 0.00 kB │ gzip: 0.02 kB
dist/client/assets/_sitemap.xml_-l0sNRNKZ.js 0.00 kB │ gzip: 0.02 kB
dist/client/assets/_robots.txt_-l0sNRNKZ.js 0.00 kB │ gzip: 0.02 kB
dist/client/assets/account._-l0sNRNKZ.js 0.00 kB │ gzip: 0.02 kB
dist/client/assets/cart._lines-C6d-v1ok.js 0.05 kB │ gzip: 0.07 kB
dist/client/assets/_-DtCUJE-g.js 0.05 kB │ gzip: 0.07 kB
dist/client/assets/search-DOeYwaXi.js 0.28 kB │ gzip: 0.23 kB
dist/client/assets/policies._index-4NTjGtIu.js 0.34 kB │ gzip: 0.24 kB
dist/client/assets/pages._handle-Dufxj4_B.js 0.36 kB │ gzip: 0.28 kB
dist/client/assets/cart-B0rRlrqG.js 0.46 kB │ gzip: 0.32 kB
dist/client/assets/policies._handle-CdXLOhXE.js 0.47 kB │ gzip: 0.32 kB
dist/client/assets/variants-LfRANlwX.js 0.49 kB │ gzip: 0.33 kB
dist/client/assets/PaginatedResourceSection-DUfPxs00.js 0.52 kB │ gzip: 0.31 kB
dist/client/assets/blogs._index-gOafM-r5.js 0.55 kB │ gzip: 0.35 kB
dist/client/assets/blogs._blogHandle._articleHandle-DLsXo3sL.js 0.66 kB │ gzip: 0.44 kB
dist/client/assets/collections._index-BAUK3q39.js 0.81 kB │ gzip: 0.47 kB
dist/client/assets/account-O9XIh7jX.js 0.98 kB │ gzip: 0.50 kB
dist/client/assets/collections.all-sF9ztxmC.js 1.00 kB │ gzip: 0.57 kB
dist/client/assets/blogs._blogHandle._index-BVPo3hTv.js 1.10 kB │ gzip: 0.61 kB
dist/client/assets/account.profile-CGR9g17i.js 1.15 kB │ gzip: 0.54 kB
dist/client/assets/collections._handle-DUxuXaJ7.js 1.22 kB │ gzip: 0.64 kB
dist/client/assets/account.orders._index-8pHtJ2F2.js 1.29 kB │ gzip: 0.63 kB
dist/client/assets/ProductPrice-yICtx8Rz.js 1.29 kB │ gzip: 0.67 kB
dist/client/assets/_index-B5yAY_tm.js 1.32 kB │ gzip: 0.63 kB
dist/client/assets/log-seo-tags-TY72EQWZ-DCHH-_Gl.js 1.32 kB │ gzip: 0.69 kB
dist/client/assets/account.orders._id-D1k2kULh.js 2.88 kB │ gzip: 0.91 kB
dist/client/assets/Money-BQP0wEmB.js 2.96 kB │ gzip: 1.27 kB
dist/client/assets/search-DIb3-BTW.js 3.65 kB │ gzip: 1.35 kB
dist/client/assets/entry.client-B8_e452P.js 3.80 kB │ gzip: 1.45 kB
dist/client/assets/Image-B8MFQSH8.js 4.11 kB │ gzip: 1.66 kB
dist/client/assets/account.addresses-AltA_HjW.js 4.68 kB │ gzip: 1.34 kB
dist/client/assets/CartMain-GvDYCxeL.js 5.50 kB │ gzip: 1.95 kB
dist/client/assets/root-CAiD-aRw.js 13.30 kB │ gzip: 4.46 kB
dist/client/assets/index-D9r4M8R3.js 33.26 kB │ gzip: 11.67 kB
dist/client/assets/components-CrrQxqco.js 257.56 kB │ gzip: 82.90 kB
dist/client/assets/products._handle-DdbnxwjH.js 1,893.77 kB │ gzip: 432.47 kB
(!) Some chunks are larger than 500 kB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
✓ built in 49.28s
vite v5.4.14 building SSR bundle for production...
✓ 1470 modules transformed.
dist/server/oxygen.json 0.06 kB
dist/server/assets/favicon-DZkC1E9c.svg 0.69 kB
dist/server/.vite/manifest.json 1.10 kB
dist/server/metafile.server.json 315.60 kB
dist/server/server-bundle-analyzer.html 377.26 kB
dist/server/assets/reset-BKioPaen.css 1.23 kB
dist/server/assets/app-CFDV3s0Q.css 5.60 kB
dist/server/index.js 2,406.60 kB │ map: 11,897.56 kB
✓ built in 1m 7s
│
├ node_modules/@shapediver/viewer.data-engine.geometry-engine/dist/gltfv2/draco/draco_decoder.js
620.3kb 26.4%
├ node_modules/@shapediver/viewer.settings/node_modules/zod/lib/types.js
69.7kb 3.0%
├ node_modules/@shapediver/viewer.shared.types/node_modules/zod/lib/types.js
67.5kb 2.9%
├ node_modules/@shapediver/viewer.session-engine.session-engine/dist/implementation/SessionEngine.js
50.9kb 2.2%
├ node_modules/@shapediver/sdk.geometry-api-sdk-core/node_modules/axios/dist/browser/axios.cjs
41.9kb 1.8%
├ node_modules/@shapediver/sdk.sdtf-v1/node_modules/axios/dist/browser/axios.cjs
39.7kb 1.7%
├ node_modules/decimal.js/decimal.js
31.5kb 1.3%
├ node_modules/dompurify/dist/purify.js
21.4kb 0.9%
├ node_modules/@shapediver/viewer.shared.types/dist/implementation/material/MaterialMultiPointData.js
20.9kb 0.9%
├ node_modules/@shapediver/viewer.data-engine.gltf-converter/dist/GLTFConverter.js
20.5kb 0.9%
│
└─── Complete analysis: file://C:/Users/SebastianMeckovski/repos/shopfiy-shapediver-poc/dist/server/server-bundle-analyzer.html ( file://C:/Users/SebastianMeckovski/repos/shopfiy-shapediver-poc/dist/server/server-bundle-analyzer.html )
Deploying to Oxygen..
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Verifying deployment has been completed ...
Deployment failed, error: Uncaught Error: Disallowed operation called within global scope. Asynchronous I/O (ex: fetch() or connect()), setting a timeout, and generating random values are not allowed within global scope. To fix this error, perform this operation within a handler. https://developers.cloudflare.com/workers/runtime-apis/handlers/
at worker.mjs:1587:123667 in t3e
at worker.mjs:1587:127162 in create
at worker.mjs:1590:265308 in YPe
at worker.mjs:1590:271075 in QPe
at worker.mjs:1590:271166 in get instance
at worker.mjs:1601:899454
╭─ error ──────────────────────────────────────────────────────────────────────╮
│ │
│ Uncaught Error: Disallowed operation called within global scope. │
│ Asynchronous I/O (ex: fetch() or connect()), setting a timeout, and │
│ generating random values are not allowed within global scope. To fix this │
│ error, perform this operation within a handler. │
│ https://developers.cloudflare.com/workers/runtime-apis/handlers/ │
│ at worker.mjs:1587:123667 in t3e │
│ at worker.mjs:1587:127162 in create │
│ at worker.mjs:1590:265308 in YPe │
│ at worker.mjs:1590:271075 in QPe │
│ at worker.mjs:1590:271166 in get instance │
│ at worker.mjs:1601:899454 │
│ │
│ │
│ Retrying the deployment may succeed. │
│ │
│ Next steps │
│ • If the issue persists, please check the Shopify status page [1] for │
│ any known issues. │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Verifying deployment has been completed ...
Reacted by Bret Little
Activity
blittle commentedon Mar 24, 2025
@sebastian-meckovski I get a 500 error attempting to follow the steps you provided:
What happens if you run the preview locally?
npm run previeworshopify hydrogen preview --buildsebastian-meckovski commentedon Mar 24, 2025
@blittle
npm run previewoutput:shopify hydrogen preview --buildoutput:I don't have it installed locally, but I can install it if it helps/
You should be able to reproduce it if you implement that
createSessioncode as in this branch inproducts.$handle.tsx. It needs to be inside UseEffect and fired on the client side. This needs to run on localhost:3000 because the backend service checks for origin header. Or you can try forking the repo.Let me know if you need more inforamtion.
sebastian-meckovski commentedon Mar 24, 2025
@blittle The way you will know that the code has worked is that if you navigate to product page, the session will be created successfully it will log in console on the browser web tools
blittle commentedon Mar 24, 2025
npm run previewruns theshopify hydrogen previewcommand for you. The preview command builds a hyrogen project in prod mode and runs it as a worker locally. And we are seeing the same error:I'm pretty sure this means that the built prod version of
shapediveris a bit different than the dev version. Oxygen runs on a Cloudflare worker, and Cloudflare workers do not allow async code to be executed statically outside a function. I think you might need to open issue with them to figure out how/where that might be happening.sebastian-meckovski commentedon Apr 8, 2025
Is there a way to "force" these packages to only be included in the client side? These
shapediverpackages are meant to be used only on the client side only, they shouldn't run on Cloudflare workerssebastian-meckovski commentedon Apr 10, 2025
@blittle
sebastian-meckovski commentedon Apr 12, 2025
I managed to make it work and deploy it by using dynamic imports. I believe this way it prevents it from compiling on the server side.
And also had to add shapediver dependencies as
externalinvite.config.tsThis fixes the deployment process.
However this no longer works n Hydrogen 2025.3.1 and Remix 2.16.1, errors locally. I created a separate issue for this