hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

Uncaught Error: Some functionality, such as asynchronous I/O, timeouts, and generating random values, can only be performed while handling a request.

Open danielmoraes opened this issue 2 years ago • 3 comments

What is the location of your example repository?

No response

Which package or tool is having this issue?

Hydrogen

What version of that package or tool are you using?

2023.7.1

What version of Remix are you using?

1.19.1

Steps to Reproduce

  • Upgrade Hydrogen
    • @shopify/hydrogen from 2023.4.6 to 2023.7.1
  • Upgrade Remix
    • @remix-run/css-bundle from 1.17.1 to 1.19.1
    • @remix-run/dev from 1.17.1 to 1.19.1
    • @remix-run/react from 1.17.1 to 1.19.1
  • Upgrade Remix Oxygen
    • @shopify/remix-oxygen from 1.1.1 to 1.1.2

Expected Behavior

The shopify/oxygenctl-action@v4 action succeeds.

Actual Behavior

The shopify/oxygenctl-action@v4 action fails at the "Uploading deployment..." step with:

InvalidScriptError: retrying will not succeed. The following error must be actioned: Uncaught Error: Some functionality, such as asynchronous I/O, timeouts, and generating random values, can only be performed while handling a request.

image

danielmoraes avatar Aug 02 '23 18:08 danielmoraes

This is happening for us currently across multiple Hydrogen storefronts after updating to 2023.7.x

duncan-fairley avatar Aug 02 '23 18:08 duncan-fairley

Interestingly I'm also seeing this on a PR from a separate project where the only change was moving from Yarn to NPM on 2023.4.6

duncan-fairley avatar Aug 03 '23 06:08 duncan-fairley

After investigating further, I identified that Sentry is causing the deployment to fail. Upgrading Sentry to the latest version doesn't resolve the problem.

More specifically, here's the line (in entry.server.tsx) that breaks the deployment:

Sentry.init({ dsn, tracesSampleRate: 1 })

danielmoraes avatar Aug 04 '23 17:08 danielmoraes

This is a limitation with Oxygen/Cloudflare where async operations need to be done within the lifecycle of a request. Make sure you use dependencies that support worker environments.

blittle avatar Jun 21 '24 20:06 blittle