Uncaught Error: Some functionality, such as asynchronous I/O, timeouts, and generating random values, can only be performed while handling a request.
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/hydrogenfrom 2023.4.6 to 2023.7.1
-
- Upgrade Remix
-
@remix-run/css-bundlefrom 1.17.1 to 1.19.1 -
@remix-run/devfrom 1.17.1 to 1.19.1 -
@remix-run/reactfrom 1.17.1 to 1.19.1
-
- Upgrade Remix Oxygen
-
@shopify/remix-oxygenfrom 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.
This is happening for us currently across multiple Hydrogen storefronts after updating to 2023.7.x
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
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 })
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.