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

Http request error, no response available: GraphQL Client: fetch failed #902

Open
watislaf opened this issue Dec 9, 2024 · 3 comments · May be fixed by Shopify/shopify-app-js#1972
Open
Assignees

Comments

@watislaf
Copy link

watislaf commented Dec 9, 2024

Hi. Absolutely randomly i am getting this error when executing graphql queries.

Image

This can happen spontaniously 1 time in 30 minutes of testing .


export async function getShopInfoQuery(admin: AdminApiContext) {
  const response = await admin.graphql(`#graphql
  query getShop {
    shop {
      id
      contactEmail
      name
      primaryDomain {
        host
      }
    }
  }
  `)

  const responseJson = await response.json()
  return responseJson?.data?.shop
}

This is query request. Nothing unusual . It works perfectly 99% of time.

I have been trying to check if this is an issue of too many requests - but it is not, too may requests creates another error and i am way beyond too many requests.

I am using same versions as : https://github.com/Shopify/shopify-app-template-remix/blob/main/package.json

I aslo tried to send 100 requests and check if there will be an error - no error at all, only sometimes spontaniously : /

@watislaf
Copy link
Author

watislaf commented Dec 9, 2024

@watislaf
Copy link
Author

watislaf commented Jan 8, 2025

Hi, my solution to this was to wrap every shopify request into try catch and repeat . It is a workaround of an issue but it worked

@lizkenyon lizkenyon self-assigned this Jan 15, 2025
@lizkenyon
Copy link
Contributor

lizkenyon commented Jan 15, 2025

Hi there 👋

The fetch failed error is what you will get when the underlying fetch request does not get a response/ throws an error. This could be due to a variety of issue like timeouts or network connectivity issue. Unfortunately things like this may happen from time to time.

Your solution to try catch, and retry the error is one option for handling these types of scenarios. But we do have a library feature that should automatically retry the request for you if this type of error happens. You will need to specify that the request should be, and is safe to be retried.

Image
  const response = await graphql(
    `#graphql
      mutation populateProduct($product: ProductCreateInput!) {
        productCreate(product: $product) {
          product {
            id
            variants(first: 10) {
              edges {
                node {
                  id
              }
            }
          }
        }
      }`,
    {
      variables: {
        product: {
          title: `${color} Snowboard`,
        },
      },
+   tries: 2,
    },
  );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants