question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: socket hang up in Node 4.2.1 (but not 0.12)

See original GitHub issue

Hello!

I’m trying to debug this issue: https://github.com/blakmatrix/node-zendesk/issues/110

Having looked into it a bit, it looks like it is a bug in request—the only alternative could be that the API I’m making requests to is rejecting the useragent with node/4.2.1 in and not the one with node/0.12 in.

request is being passed the same data in both versions of Node, and is being called multiple times. It never fails on the first time it is called, it usually fails between the third and sixth times—it’s being passed only slightly different data (page numbers), but sporadically fails.

This is some sample data that sometimes succeeds and sometimes fails:

{ stores:
   { defaults:
      Literal {
        type: 'literal',
        store: [Object],
        mtimes: {},
        readOnly: true,
        loadFrom: null,
        logicalSeparator: ':' } },
  sources: [],
  headers:
   { 'Content-Type': 'application/json',
     Accept: 'application/json',
     'User-Agent': 'node-zendesk/1.1.5 (node/4.2.1)',
     Authorization: 'Basic [redacted]' },
  uri: 'https://[redacted].zendesk.com/api/v2/search.json?page=3&query=checkout-failure',
  method: 'GET' }

And request is being given the following defaults:

{ jar: RequestJar { _jar: CookieJar { store: { idx: {} } } },
  encoding: null,
  timeout: 240000,
  proxy: null,
  secureOptions: 134217728 }

The following error is (eventually) thrown:

Error: socket hang up
    at createHangUpError (_http_client.js:203:15)
    at TLSSocket.socketOnEnd (_http_client.js:288:23)
    at emitNone (events.js:72:20)
    at TLSSocket.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:903:12)
    at doNTCallback2 (node.js:439:9)
    at process._tickCallback (node.js:353:17)

What could be causing this? Is this a bug in request, or is there something wrong with how we’re calling it?

I’m too far deep into a library I am unfamiliar with to make a stripped down test case. If necessary, I can make one—wanted to check it wasn’t something obvious before investing the time, first, though.

Here is where request is initiated: https://github.com/blakmatrix/node-zendesk/blob/master/lib/client/client.js#L35-L41
Here is where it is called: https://github.com/blakmatrix/node-zendesk/blob/master/lib/client/client.js#L100-L102

Help would be much appreciated, thanks!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:15

github_iconTop GitHub Comments

1reaction
shawn-msftcommented, Feb 7, 2017

Did you use a keepAlive socket? If the server requires a keep-alive connection , and your headers doesn’t include the keep-alive option and it will return an socket hang up error. and the most important is , In node 0.12, setting ‘Connection’: ‘Keep-Alive’ property in http option will work. But in node 4.0 or above, if you would like to use keep-alive connection, you have to create an agent and set its keepAlive property to true. So,in this situation, the same code will work on 0.12 but won’t work anymore on 4.0. I hope this will help you .

0reactions
stale[bot]commented, Apr 3, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NodeJS - What does "socket hang up" actually mean?
It means that socket does not send connection end event within the timeout period. If you are getting the request for cheerio via...
Read more >
Socket hang up problems - Google Groups
Hi, I've been getting this issue every now and then on a long poll request. It doesn't happen consistently so I'm finding it...
Read more >
Node.js ChangeLog - Google Git
Some problems with unreferenced timers running during beforeExit are still to be resolved. See #1264. Surrogate pair in REPL can freeze terminal. #690;...
Read more >
Bug listing with status RESOLVED with resolution TEST ...
status:RESOLVED resolution:TEST-REQUEST severity:critical · Bug:3888 - "yenta_socket module not included on install CD" status:RESOLVED ...
Read more >
Changelog - Cypress Documentation
Fixed a bug where projects using Node.js 16.17+ and 18.6+ with ES Modules and TypeScript were not working with Cypress. Fixes #22795, #23393,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found