Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix app crash on prod #1794

Open
wants to merge 13 commits into
base: v1.x-2022-07
Choose a base branch
from
9 changes: 8 additions & 1 deletion packages/hydrogen/src/hooks/useShopQuery/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {fetchSync} from '../../foundation/fetchSync/server/fetchSync';
import {META_ENV_SSR} from '../../foundation/ssr-interop';
import {getStorefrontApiRequestHeaders} from '../../utilities/storefrontApi';
import {parseJSON} from '../../utilities/parse';
import {findQueryName} from '../../utilities/log/utils';

export interface UseShopQueryResponse<T> {
/** The data returned by the query. */
Expand Down Expand Up @@ -91,7 +92,13 @@ export function useShopQuery<T>({
try {
data = response.json();
} catch (error: any) {
useQueryError = new Error('Unable to parse response:\n' + text);
useQueryError = new Error(
`Unable to parse ${findQueryName(
query
)} response (x-request-id: ${response.headers.get(
'x-request-id'
)}):\n${text}`
);
}
} catch (error: any) {
// Pass-through thrown promise for Suspense functionality
Expand Down
2 changes: 1 addition & 1 deletion templates/demo-store/hydrogen.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
defaultCountryCode: 'US',
defaultLanguageCode: 'EN',
storeDomain: 'hydrogen-preview.myshopify.com',
storefrontToken: '3b580e70970c4528da70c98e097c2fa0',
storefrontToken: '174af69ea23ab0c1d7191f13fd82ea3c',
storefrontApiVersion: '2022-07',
},
session: CookieSessionStorage('__session', {
Expand Down
8 changes: 4 additions & 4 deletions templates/demo-store/src/routes/index.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function Homepage() {

return (
<Layout>
<Suspense>
<Suspense fallback="">
<SeoForHomepage />
</Suspense>
<Suspense>
Expand Down Expand Up @@ -86,7 +86,7 @@ function HomepageContent() {
function SeoForHomepage() {
const {
data: {
shop: {title, description},
shop: {name: title, description},
},
} = useShopQuery({
query: HOMEPAGE_SEO_QUERY,
Expand Down Expand Up @@ -168,9 +168,9 @@ const HOMEPAGE_CONTENT_QUERY = gql`
`;

const HOMEPAGE_SEO_QUERY = gql`
query homeShopInfo {
query shopInfo {
shop {
title: name
name
description
}
}
Expand Down