Skip to content

Uncaught Error: Disallowed operation called within global scope. #2805

@sebastian-meckovski

Description

@sebastian-meckovski

What is the location of your example repository?

https://github.com/sebastian-meckovski/shopfiy-shapediver-poc/tree/debug-branch

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

  1. Scaffold Shopify Hydrogen project using npm create @shopify/hydrogen@latest
  2. Install NPM package @shapediver/viewer.session
  3. Update vite.config.ts optimizeDeps to include @shapediver/viewer.session
  4. Update entry.server.tsx security policy
    connectSrc: [
      'https://sdr8euc1.eu-central-1.shapediver.com'
    ]
  1. 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 ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions