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

admin-api-client + node-fetch erroring since a few days: Client network socket disconnected before secure TLS connection was established #1851

Open
4 tasks done
b0dea opened this issue Dec 10, 2024 · 2 comments
Labels

Comments

@b0dea
Copy link

b0dea commented Dec 10, 2024

Issue summary

Before opening this issue, I have:

  • Upgraded to the latest version of the relevant packages
    • @shopify/admin-api-client package and version: 1.0.4 + node-fetch 2.7.0 (as a fetch agent)
    • Node version: 18.20.4
    • Operating system: Deployed on AWS ECS/ECR
  • Found a reliable way to reproduce the problem that indicates it's a problem with the package
  • Looked for similar issues in this repository
  • Checked that this isn't an issue with a Shopify API

This happens even on the deployed app that never had issues. We have the app deployed on AWS ECR/ECS.

Below you can find errors happening continuously:

I was reading around

And it seems now we have to do some kind of a proxy. This has not happened since last week. We changed nothing in our system, and it has started spitting this error out. So, I am not sure what I should try now and how I should change the code so it works:

const fetch = require('node-fetch');

this.shopify = createAdminRestApiClient({
            storeDomain: process.env.SHOPIFY_URL,
            apiVersion: '2024-10',
            accessToken: process.env.SHOPIFY_ADMIN_API_TOKEN,
            customFetchApi: fetch
        });
@b0dea
Copy link
Author

b0dea commented Dec 12, 2024

Notes on above

  1. I have created a proxy in AWS and then added it with https-proxy-agent but it does not work, the error still happens.
  2. The only way it currently works is if I use, with the node-fetch instance, a reject unauthorized param on a https agent
        const httpsAgent = new https.Agent({
            rejectUnauthorized: false // Disables TLS certificate validation (not good for long term use)
        });

 const customFetch = (url, options = {}) => {
            options.agent = httpsAgent; // Add the custom agent to each request
            return fetch(url, options);
        };

        this.shopify = createAdminRestApiClient({
            storeDomain: process.env.SHOPIFY_URL,
            apiVersion: '2024-10',
            accessToken: process.env.SHOPIFY_ADMIN_API_TOKEN,
            customFetchApi: customFetch // Pass the custom fetch API
        });

However, now I keep getting socket hang up errors at random times. However, no TLS issues anymore.

Copy link
Contributor

We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.

You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.

@github-actions github-actions bot added the Stale label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant