Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Server Side Exception has occurred while loading the localhost #1473#1475

Open
samandeepbishnoi wants to merge 2 commits intovercel:main from
samandeepbishnoi:fix/server-side-exception
Open

fix: Server Side Exception has occurred while loading the localhost #1473 #1475
samandeepbishnoi wants to merge 2 commits intovercel:main from
samandeepbishnoi:fix/server-side-exception

Conversation

@samandeepbishnoi
Copy link

@samandeepbishnoi samandeepbishnoi commented Jul 7, 2025

Problem

When running the project locally with Shopify as the provider, a server-side exception crashes the app during layout rendering

Root cause:

  • shopifyFetch() throws a non-standard object (throw {}), which cannot be caught by try/catch or error boundaries in React.
  • getCart() does not handle failed fetches or missing cart data.
  • SHOPIFY_GRAPHQL_API_ENDPOINT was used as a relative path, which breaks SSR fetch requests if environment variables are not configured properly.

✅ What This PR Fixes

  • Wraps getCart() logic in a try/catch block to prevent layout crashes.
  • Replaces throw {} in shopifyFetch() with standard Error instances for compatibility with error boundaries.
  • Adds detailed logging for easier debugging of Shopify GraphQL errors and fetch failures.
  • Ensures endpoint is constructed correctly using the full store domain and versioned API path.
  • Updates .env.example to include SHOPIFY_STOREFRONT_API_VERSION.

🧪 Verification

  • npm run dev works with correct .env.local setup
  • ✅ Page loads even if no cart cookie exists
  • ✅ API errors from Shopify are logged but no longer crash the app
  • ✅ Cart gracefully falls back to undefined if invalid or missing

⚠️ Developer Note

Make sure your .env.local file is correctly set up with valid credentials and fully qualified Shopify domain

Copy link
Contributor

vercel bot commented Jul 7, 2025

Someone is attempting to deploy a commit to the Vercel Solutions Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Author

Hi team 👋,

This is my first open-source contribution — I fixed a Shopify layout crash caused by unhandled API errors and misconfigured endpoint logic. The PR ensures proper error handling in shopifyFetch, wraps getCart() in try/catch, and fixes environment-based endpoint generation.

Would love a review or feedback — happy to make changes! 🙌

Thanks for maintaining this amazing project 🚀

Copy link
Author

samandeepbishnoi commented Jul 8, 2025
edited
Loading

Thank you for the detailed review! 🙏
I've made the requested changes:

Removed package-lock.json as the repo uses pnpm.

Updated .env.example with SHOPIFY_STOREFRONT_API_VERSION=2025-07 as per latest docs.

Fixed the extra tabbing headers in shopifyFetch().

codingChewie reacted with thumbs up emoji

Copy link

brienna commented Jul 22, 2025

+1 this helped fix my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

3 more reviewers

@codingChewie codingChewie codingChewie approved these changes

@DSZ99 DSZ99 DSZ99 approved these changes

@servergetaway-ui servergetaway-ui servergetaway-ui approved these changes

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Comments

AltStyle によって変換されたページ (->オリジナル) /