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

Socket timeout slower response #1368

Open
1 task done
henkspane opened this issue Sep 29, 2022 · 8 comments
Open
1 task done

Socket timeout slower response #1368

henkspane opened this issue Sep 29, 2022 · 8 comments
Labels
triage-needed Issues that need to be checked

Comments

@henkspane
Copy link

henkspane commented Sep 29, 2022

What is your question / Please describe your issue

What is your question / Please describe your issue
We are performing requests using GraphQL queries by Apollo. When a query response is slow (+-10 seconds), the storefront will throw a socket timeout error. Example:

[VSF][error]: [Network error]: FetchError: request to https://test.environment.example/graphql?query=query+categoryList%7Bcategories%7Bitems%7Bchildren%7Binclude_in_menu+is_anchor+level+name+position+product_count+uid+url_path+url_suffix+children%7Binclude_in_menu+is_anchor+level+name+position+product_count+uid+url_path+url_suffix+children%7Binclude_in_menu+is_anchor+level+name+position+product_count+uid+url_path+url_suffix+__typename%7D__typename%7D__typename%7Dproduct_count+name+uid+__typename%7D__typename%7D%7D&operationName=categoryList&variables=%7B%7D failed, reason: Socket timeout

The socket timeout is a problem in local environments.

I am not able to see a global configuration setting in Vue storefront for changing the default socket timeout for all queries. Is there a way to do this?

What version of Magento 2 Integration are you using?

1.0.1

Code of Conduct

  • I agree to follow this project's Code of Conduct
@henkspane henkspane added the triage-needed Issues that need to be checked label Sep 29, 2022
@sequensucks
Copy link
Contributor

packages/api-client/src/helpers/magentoLink/graphQl.ts:21

Need to add params for timeout. Default is 15sec.
For example,
const agent = new HttpsAgent({
keepAlive: true,
freeSocketTimeout: 60_000,
});

Docs,
https://www.npmjs.com/package/agentkeepalive/v/4.0.0?activeTab=readme#new-agentoptions

@henkspane
Copy link
Author

henkspane commented Oct 18, 2022

@sequensucks We use Apollo and have only the following file: node_modules/@vue-storefront/magento-api/lib/helpers/magentoLink/graphQl.d.ts:

import { ApolloClient, ApolloLink } from '@apollo/client/core';
import { Config } from '../../types/setup';
export declare const apolloLinkFactory: (settings: Config, handlers?: {
    apolloLink?: ApolloLink;
}) => ApolloLink;
export declare const apolloClientFactory: (customOptions: Record<string, any>) => ApolloClient<import("@apollo/client/core").NormalizedCacheObject>;

I do not understand how we can use the configuration you mentioned.

@KrisRogozinski
Copy link

KrisRogozinski commented Nov 7, 2022

@henkspane you're looking into 'declaration file' that is generated and available in your node_modules. File mention by @sequensucks is available in VSF Magento package. If you've generated VSF website with the CLI you don't have it in your project but only reference in node_modules.
So clearly you looking in wrong place.
The issue itself is related to the connection between VSF and Magento, that is taking too long.

@JesseMaxwell
Copy link

JesseMaxwell commented Apr 27, 2023

The timeout seems to be much shorter than 15s – perhaps 7-8s. It is short enough that legitimate requests (place order) are affected.

Are there any workarounds available?

@andreiRC1
Copy link

andreiRC1 commented Dec 11, 2023

Has anyone found any solution to this problem? We are using version 1.1.0 and facing the same issue, there is a timeout of around 8s for requests from VSF to Magento

Edit: I have managed to fix it by adding the following code in middleware.config.js -> inside integrations.magento.customApolloHttpLinkOptions
fetchOptions: { timeout: 20_000, },

@simonmaass
Copy link

We are also seeing this error on a couple of order placements!

@JesseMaxwell
Copy link

For what it's worth, I think this is a major bug especially since there is no known workaround.

@simonmaass
Copy link

Has anyone found any solution to this problem? We are using version 1.1.0 and facing the same issue, there is a timeout of around 8s for requests from VSF to Magento

Edit: I have managed to fix it by adding the following code in middleware.config.js -> inside integrations.magento.customApolloHttpLinkOptions fetchOptions: { timeout: 20_000, },

This worked for us

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Issues that need to be checked
Projects
None yet
Development

No branches or pull requests

6 participants