From a89d1e106629c40d3ec893789faca98ead283027 Mon Sep 17 00:00:00 2001 From: Bartosz Herba Date: Wed, 20 Nov 2024 09:48:44 +0100 Subject: [PATCH] feat: increase the HttpAgent socket timeout (#1553) --- .changeset/cold-peas-rush.md | 5 +++++ packages/api-client/src/helpers/magentoLink/graphQl.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/cold-peas-rush.md diff --git a/.changeset/cold-peas-rush.md b/.changeset/cold-peas-rush.md new file mode 100644 index 000000000..f1bfa03f0 --- /dev/null +++ b/.changeset/cold-peas-rush.md @@ -0,0 +1,5 @@ +--- +"@vue-storefront/magento-api": minor +--- + +** [CHANGED] ** - increase the HttpAgent socket timeout from `10s` to `30s` to prevent timeout errors on slow connections. diff --git a/packages/api-client/src/helpers/magentoLink/graphQl.ts b/packages/api-client/src/helpers/magentoLink/graphQl.ts index 8d2d76858..e114f6cd2 100644 --- a/packages/api-client/src/helpers/magentoLink/graphQl.ts +++ b/packages/api-client/src/helpers/magentoLink/graphQl.ts @@ -11,7 +11,9 @@ import possibleTypes from "../../types/possibleTypes.json"; import standardURL from "../url/standardURL"; const { HttpsAgent } = AgentKeepAlive; -const agent = new HttpsAgent(); +const agent = new HttpsAgent({ + timeout: 30000, +}); const createErrorHandler = () => onError(({ graphQLErrors, networkError }) => { @@ -48,7 +50,7 @@ export const apolloLinkFactory = ( ) => { const baseLink = handlers?.apolloLink || - setContext((apolloReq, { headers }) => ({ + setContext((_apolloReq, { headers }) => ({ headers: { ...headers, },