commerce: GetStaticProps Not working as expected on vercel Returning -1 HTTP error

Hi team,

So I have a very large number of products, so I can’t use getSataticPaths as the build time exceeds 45 minutes (with shopify API rate limit throttling) (plus who wants to wait that long anyway)

[slug].js

export async function getStaticPaths({ locales }: GetStaticPathsContext) {
  const { products } = await getAllProductPaths()

  // we have too many products, static rendering will be done the first time a product is loaded up
  return {
    paths: [],
    fallback: true,
  }
}

Now this works perfectly on my local machine that builds everything every time. But on production its giving unexpected results on some products (not all). These products also work on my local environment which makes this super hard to debug:

https://storefront-7aja4imda-colabpantry.vercel.app/products/chutney-maison

Logs:

Screen Shot 2021-06-23 at 12 20 38 pm

Logs of a product that works: Screen Shot 2021-06-23 at 12 21 34 pm

Now if you are returning HTTP statuses, what does a status of -1 mean?

PS. I’m sorry I’m posting this here, I’ve submitted 2 detailed support tickets and both times they have told me to check the logs.

Its also worth noting that I can fix the issue by providing all the build paths eg.

[slug.js] (working - but build time exceeds 45 minutes)

export async function getStaticPaths({ locales }: GetStaticPathsContext) {
  const { products } = await getAllProductPaths()

  // we have too many products, static rendering will be done the first time a product is loaded up
  return {
    paths: products.map((product) => `/products${product.node.path}`),
    // paths: [],
    fallback: true,
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

@achadee is a rate limit error that happens because on your getProduct query. You query too much for each product, so makes that query expensive. And by the time it reaches that product it throws that throttled error

Screenshot 2021-06-29 at 14 36 07

If Shopify measures that by the time first request happened until last response (by IP), lambda being slower than your machine maybe that’s the answer why on your local machine never happens (I managed to see build errors on mine too). And on my cloned one it stopped and generated at exact product 😃.

Screenshot 2021-06-29 at 14 30 45

After i removed the ‘collections’ part from your get product query and replaced with official product recommendations query, it seems to work, without generating 500 errors. As you can see on link bellow

https://storefront-pi.vercel.app/products/chutney-maison

Make sure you give me access to push the changes to another branch so you can merge if you want.