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

failed, reason: socket hang up and status 500 #195

Open
1 of 7 tasks
hawx1993 opened this issue Sep 1, 2022 · 13 comments
Open
1 of 7 tasks

failed, reason: socket hang up and status 500 #195

hawx1993 opened this issue Sep 1, 2022 · 13 comments
Labels
Type: Bug Something isn't working as documented

Comments

@hawx1993
Copy link

hawx1993 commented Sep 1, 2022

Checklist

Environment

Versions
19.0.44

What happened?

RequestError [HttpError]: request to https://api.github.com/repos/hawx1993/heaven-docs/contents/%2Fpackages%2Fheaven%2Fsrc?ref=master failed, reason: socket hang up at /Users/trigkit4/heaven-code-helper/node_modules/@octokit/request/dist-src/fetch-wrapper.js:96:15

  status: 500,
  request: {
    method: 'GET',
    url: 'https://api.github.com/repos/hawx1993/heaven-docs/contents/%2Fpackages%2Fheaven%2Fsrc?ref=master',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/19.0.4 octokit-core.js/4.0.5 Node.js/14.18.1 (darwin; x64)',
      authorization: 'token [REDACTED]'
    },
    request: { hook: [Function: bound bound register] }
  }

and as you can see, we can easily open the link api: https://api.github.com/repos/hawx1993/heaven-docs/contents/%2Fpackages%2Fheaven%2Fsrc?ref=master
so, not the github issues

Minimal test case to reproduce the problem

const octokit = new Octokit({
  auth: GITHUB_TOKEN,
});
await octokit.repos.getContent({
      owner: 'hawx1993',
      repo: 'heaven',
      path: '/packages/heaven/src',
      ref: 'master',
    });

and throw upper error

What did you expect to happen?

can get normal response data from github

What the problem might be

@hawx1993 hawx1993 added the Type: Bug Something isn't working as documented label Sep 1, 2022
@timrogers
Copy link

Hi @hawx1993! 👋🏻 Thanks for reaching out.

It sounds like there is a connectivity issue between your machine and api.github.com.

The following code works for me locally (I changed the repo from heaven to heaven-docs, as it looks like that's the correct value!):

const octokit = new Octokit();

const response = await octokit.rest.repos.getContent({
    owner: 'hawx1993',
    repo: 'heaven-docs',
    path: '/packages/heaven/src',
    ref: 'master',
});

console.log(response.data);

I have some follow-up questions:

  1. How quickly does the code error? Does it take a few seconds? Or is it instant?
  2. Is this code failing on your local development machine, or is it some other environment (e.g. a cloud provider)?
  3. Are you able to reach api.github.com with a simple HTTP request from that environment? (e.g. curl https://api.github.com --verbose)

@hawx1993
Copy link
Author

hawx1993 commented Sep 1, 2022

@timrogers hi, there!
this is my curl msg as below:

 curl https://api.github.com --verbose
*   Trying 20.205.243.168:443...
* Connected to api.github.com (20.205.243.168) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to api.github.com:443
* Closing connection 0
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to api.github.com:443

How quickly does the code error? Does it take a few seconds? Or is it instant?

is instant. I request github api meybe 100times per seconds

Is this code failing on your local development machine, or is it some other environment (e.g. a cloud provider)?

local mac machine. but I can open https://api.github.com/repos/hawx1993/heaven-docs/contents/%2Fpackages%2Fheaven%2Fsrc?ref=master on my browser.

I use axios , and it's normal

@hawx1993
Copy link
Author

hawx1993 commented Sep 1, 2022

image

added the error msg pic

@timrogers
Copy link

Thanks! It looks like your machine is having some kind of SSL or TLS issue with connecting to api.github.com, but I'm not sure why. What happens if you try to visit https://api.github.com/ in a browser?

@hawx1993
Copy link
Author

hawx1993 commented Sep 1, 2022

@timrogers

{
    "message": "API rate limit exceeded for 172.105.122.83. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
    "documentation_url": "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"
}

@hawx1993
Copy link
Author

hawx1993 commented Sep 1, 2022

@timrogers it seems my token has been limited , can I use octokit to work through it by pass same params?

@hawx1993
Copy link
Author

hawx1993 commented Sep 1, 2022

image
now it's normal, but I still can't get normal response by use octokit

@timrogers
Copy link

It does seem that your IP has been rate limited, but the issue you are having with Octokit is a different issue, as you aren't even getting a response.

Looking at the curl error message, it seems like there is a problem with the LibreSSL installation on your machine. That stops curl from talking to GitHub, and it is also likely to stop Octokit from talking to GitHub. You will need to figure out what is going on with that SSL setup, which is independent from Octokit. Sorry ☹️

@hawx1993
Copy link
Author

hawx1993 commented Sep 1, 2022

image

I can get normal response by use axios

@hawx1993
Copy link
Author

hawx1993 commented Sep 1, 2022

@timrogers ok, thx

@timrogers
Copy link

That's surprising! In that case, I'm not sure what the issue is. It's odd that it would work in Axios but not node-fetch, given that they both should use Node's http module under the hood as far as I know.

@octokit/js-community Any ideas?

@gr2m
Copy link
Contributor

gr2m commented Sep 6, 2022

I request github api meybe 100times per seconds

That could definitely be the problem. If you send more than ~1 request per second over a prolonged time you will be flagged in some way or another. The same request works through curl and the browser because you send a single request.

Another idea: can you remove the / prefix from the path option and see if that helps?

@levithomason
Copy link

levithomason commented Feb 21, 2024

If others hit this, check your VPN or DNS settings. In my case, OpenDNS was causing this same issue nondeterministically. I switched to another VPN and it works without issue. OpenDNS wasn't reporting anything blocked or blacklisted in the requests, but it will still causing it to fail.

One other oddity was that after getting an HTTP 500, if I then visited that same URL in the browser the results would load (somewhat slow), then I could retry the octokit request and it would work. This was 100% consistent in the behavior I was experiencing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

4 participants