-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/react-router
SDK Version
10.18.0
Framework Version
@shopify/hydrogen 2025.7.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
No response
Steps to Reproduce
I onboarded Sentry to my new hydrogen react router v7 project. Everything works well except for source map uploads, due to the buildEnd react router hook not executing, when I set things up as mentioned in the docs.
What is the recommendation for setting up sentry given buildEnd in react router build is not available in hydrogen deployments?
Details below:
//react-router.config.ts
import type { Config } from "@react-router/dev/config";
import { hydrogenPreset } from "@shopify/hydrogen/react-router-preset";
import { sentryOnBuildEnd } from "@sentry/react-router";
export default {
...hydrogenPreset(),
buildEnd: async ({ viteConfig, reactRouterConfig }) => {
console.log("π₯ This never prints - buildEnd hook not called!");
await sentryOnBuildEnd({ viteConfig, reactRouterConfig });
}
} satisfies Config;
//vite.config.ts
import { defineConfig } from "vite";
import { hydrogen } from "@shopify/hydrogen/vite";
import { reactRouter } from "@react-router/dev/vite";
import { sentryReactRouter } from "@sentry/react-router";
import tsconfigPaths from "vite-tsconfig-paths";
export default defineConfig({
plugins: [
hydrogen(),
reactRouter(),
sentryReactRouter(
{
org: "my-org",
project: "my-project",
authToken: process.env.SENTRY_AUTH_TOKEN,
release: {
name: "test-release",
},
debug: true,
},
{ command: 'build', mode: 'production' }
),
tsconfigPaths(),
],
build: {
sourcemap: true,
},
});
Repro:
// hydrogen by default disables client source map. enable generating as sentry will delete after uploading
npx shopify hydrogen deploy --force-client-sourcemap
Expected Result
Expected sourcemaps to be uploaded for the sentry release
Actual Result
No sourcemaps uploaded
Additional Context
The below is AI-generated from https://github.com/Shopify/hydrogen, hope it helps:
βΊ The Hydrogen CLI skips React Router's buildEnd hook because the CLI directly calls Vite's build API instead of using React Router's build orchestrator.
Looking at the build implementation (packages/cli/src/commands/hydrogen/build.ts:115-370):
- The CLI manually invokes Vite builds - It calls vite.build() twice directly (once for client at line 171, once for server at line 211), completely
bypassing React Router's build wrapper - Custom build lifecycle hooks - The CLI implements its own lifecycle hooks through custom Vite plugins (hydrogen:cli:client and hydrogen:cli:server at
lines 186-202 and 226-252) - React Router's buildEnd never executes - Since React Router's build orchestration layer is bypassed, hooks like buildEnd configured in
react-router.config.ts are never invoked
The preset explicitly blocks buildEnd usage (packages/hydrogen/src/react-router-preset.ts:86-92) and suggests workarounds:
- Use external build scripts
- Use package.json post-build hooks (e.g., "postbuild": "node ./my-script.js")
This architecture gives the Hydrogen CLI fine-grained control over the build process for Oxygen deployment optimization, but at the cost of React Router
configuration flexibility.
Tip: React with π to help prioritize this issue. Please use comments to provide useful context, avoiding +1
or me too
, to help us triage it.
Metadata
Metadata
Assignees
Projects
Status